Created
March 4, 2016 22:13
-
-
Save erikfloresq/5e42c5b6b0f21269140e to your computer and use it in GitHub Desktop.
Add toolbar in keyboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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