Created
March 27, 2017 14:36
-
-
Save JFSene/98af670306e9f748d73dbf58d708fc38 to your computer and use it in GitHub Desktop.
Add multiple buttons to PickerView's Toolbar
This file contains 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
let picker: UIPickerView | |
picker = UIPickerView(frame: CGRectMake(0, 200, view.frame.width, 300)) | |
picker.backgroundColor = .whiteColor() | |
picker.showsSelectionIndicator = true | |
picker.delegate = self | |
picker.dataSource = self | |
let toolBar = UIToolbar() | |
toolBar.barStyle = UIBarStyle.Default | |
toolBar.translucent = true | |
toolBar.tintColor = UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1) | |
toolBar.sizeToFit() | |
let doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Plain, target: self, action: "donePicker") | |
let spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil) | |
let cancelButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.Plain, target: self, action: "donePicker") | |
toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false) | |
toolBar.userInteractionEnabled = true | |
textField1.inputView = picker | |
textField1.inputAccessoryView = toolBar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment