Create a toolbar with a height of 0, then call sizeToFit . Then the toolbar will have a default height.
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, width, 0)]; [toolbar sizeToFit];
Quick version:
let toolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: width, height: 0)) toolbar.sizeToFit()
source share