Having received this problem, I found that the toolbar should either be created with a non-zero frame, or called sizeToFit .
eg.
let tb = UIToolbar() tb.translucent = false tb.items = [UIBarButtonItem.init(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil), UIBarButtonItem.init(title: "A button", style: .Plain, target: self, action: Selector("someAction:"))] tb.sizeToFit() userField?.inputAccessoryView = tb
or
let tb = UIToolbar(CGRectMake(0,0,view.frame.width,44)) tb.translucent = false tb.items = [UIBarButtonItem.init(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil), UIBarButtonItem.init(title: "A button", style: .Plain, target: self, action: Selector("someAction:"))] userField?.inputAccessoryView = tb
source share