iOS 14+ calendar style date picker. Almost a drop-in replacement of the native UIDatePicker.
- Vertical and horizontal calendar layouts
- Range selection
- "Infinite" scrolling
- UIDatePicker compatible API
- Annotations, custom ranges and more
.package(url: "https://github.com/cianru/ios-datepicker", exact: "1.0.0")
DatePickerDemo.xcworkspace
contains the example application project.
let datePicker = DatePicker()
datePicker.addAction(UIAction { _ in
print("Selected date: \(datePicker.date)")
}, for: .valueChanged)
See DatePickerProtocol.swift
for all possible parameters.
SwiftUI isn't supported yet, but you can use DatePickerUIViewRepresentable.swift
as an example UIViewRepresentable
implementation.
You can provide DatePickerSettings
with custom appearance and accessibility settings: colors, fonts, images, accessibility identifiers and labels:
var settings = DatePickerSettings()
settings.appearance.colors.text.accent = .systemRed
// Settings for specific instance
let datePicker = DatePicker(settings: settings)
Also you can change those settings globally for every instance of DatePicker
:
var settings = DatePickerSettings()
settings.appearance.colors.control.primary = .systemRed
settings.appearance.colors.control.secondary = .systemRed.withAlphaComponent(0.3)
// Global settings
DatePickerSettings.default = settings
See DatePickerSettings.swift
for all possible customization settings.