CocoaPods trunk is moving to be read-only. Read more on the blog, there are 12 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Apr 2017 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by Adam Eri.
BMPickerModal is an iOS drop-in class that displays a UIPicker or a UIDatePicker as modal view or in a popover controller on the iPad. Used to let the user select from a list of data or pick a date without leaving the current screen. Closures allow easy customisation.
Built in Swift 3 for iOS 8.0+. All devices supported. can be used in both Swift and in ObjectiveC projects.
You will need Xcode 8 for version 1.1.x and above.
For older projects using Swift 2, use version 1.0.x.
Import the module to your project.
@import BMPickerModalvar datePickerModal = BMPickerModal()
datePickerModal?.mode = .datePickerAvailable modes:
.datePicker - Default.pickerdatePickerModal?.show({ (selectedDate) -> Void in
let theNewDate = selectedDate as! NSDate
// Do something with the date here
})Checking whether the control is visible
let visible: Bool = datePickerModal.isVisibleselection: Closure to be executed when date/data is selected sourceView: View to show from sourceRect: CGRect to align to inViewController: ViewController used to present the modal
datePickerModal?.showInPopover({ (selectedDate) -> Void in
let theNewDate = selectedDate as! NSDate
// Do something with the date here
}, sourceView: self.view, sourceRect: cell!.frame, inViewController: self)Checking whether the control is shown in a popover
let inPopover: Bool = datePickerModal.shownInPopoverdatePickerModal?.dismiss()You can add custom actions to the dismissal event by defining the onDismiss closure.
datePickerModal?.ondismiss()Access the UIDatePicker view and cusomise as per the Apple documentation.
datePickerModal?.datePicker.datePickerMode = UIDatePickerMode.dateSet the pickerDataSource NSArray property for filling the UIPickerView.