This is a
UIControl subclass that allows date selection using month and year, unlike
UIDatePicker which displays year, month, and day. This makes
MonthYearPicker useful for credit card expiry dates, for example. It is locale-aware and shows localised values. It also supports Dynamic Type and dark mode where available.
MonthYearPicker in the same way you would a
let picker = MonthYearPickerView(frame: CGRect(origin: CGPoint(x: 0, y: (view.bounds.height - 216) / 2), size: CGSize(width: view.bounds.width, height: 216))) picker.minimumDate = Date() picker.maximumDate = Calendar.current.date(byAdding: .year, value: 10, to: Date()) picker.addTarget(self, action: #selector(dateChanged(_:)), for: .valueChanged) view.addSubview(picker)
iOS 9.0 or later
MonthYearPicker is available through CocoaPods or Swift Package Manager.
Add the following line to your Podfile:
pod "MonthYearPicker", '~> 4.0.2'
Swift Package Manager
From within Xcode, select File → Swift Packages → Add Package Dependency... and enter
Alexander Edge, [email protected]
MonthYearPicker is available under the MIT license. See the LICENSE file for more info.