This is a UIDatePicker
subclass that allows date selection using month / year. It is locale-aware and shows localised values.
Initialise the picker just like you would UIPickerView
. You can set a closure to execute when the date changes using the dateSelectionHandler
property.
let picker = MonthYearPickerView(frame: CGRect(origin: CGPoint(x: 0, y: (CGRectGetHeight(view.bounds) - 216) / 2), size: CGSize(width: CGRectGetWidth(view.bounds), height: 216)))
picker.dateSelectionHandler = { date in
print("selected: \(date)")
}
self.view.addSubview(picker)
iOS 8.0 or later
MonthYearPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MonthYearPicker"
Alexander Edge, alex@alexedge.co.uk
MonthYearPicker is available under the MIT license. See the LICENSE file for more info.