Skip to content

Instantly share code, notes, and snippets.

@erikfloresq
Created March 4, 2016 22:13
Show Gist options
  • Save erikfloresq/5e42c5b6b0f21269140e to your computer and use it in GitHub Desktop.
Save erikfloresq/5e42c5b6b0f21269140e to your computer and use it in GitHub Desktop.
Add toolbar in keyboard
class func setUpToolBar(txtField:UITextField, vista:UIViewController){
let btn1:UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)
let btn2:UIBarButtonItem = UIBarButtonItem(title: "Listo", style: UIBarButtonItemStyle.Done, target: nil, action: "hideKeyboard")
btn2.tintColor = UIColor.blackColor()
let items:NSArray = [btn1,btn2]
let toolBar: UIToolbar = UIToolbar(frame: CGRectMake(0,0,vista.view.frame.size.width,40))
toolBar.barStyle = UIBarStyle.Default
toolBar.barTintColor = UIColor.lightTextColor()
toolBar.setItems(items as? [UIBarButtonItem], animated: true)
txtField.inputAccessoryView = toolBar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment