Skip to content

Commit 118e313

Browse files
datePickerStyle for DateFieldRow and DatePickerCell (#2077)
* DatePickerStyle for DateFieldRow and DatePickerRow Co-authored-by: Mathias Claassen <mathias@xmartlabs.com>
1 parent e1bb4d6 commit 118e313

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Source/Rows/Common/DateFieldRow.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ open class DateCell: Cell<Date>, CellType {
5151
editingAccessoryType = .none
5252
datePicker.datePickerMode = datePickerMode()
5353
datePicker.addTarget(self, action: #selector(DateCell.datePickerValueChanged(_:)), for: .valueChanged)
54+
55+
#if swift(>=5.2)
56+
if #available(iOS 13.4, *) {
57+
datePicker.preferredDatePickerStyle = .wheels
58+
}
59+
#endif
5460
}
5561

5662
deinit {

Source/Rows/DatePickerRow.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ open class DatePickerCell: Cell<Date>, CellType {
5353
height = { UITableView.automaticDimension }
5454
datePicker.datePickerMode = datePickerMode()
5555
datePicker.addTarget(self, action: #selector(DatePickerCell.datePickerValueChanged(_:)), for: .valueChanged)
56+
57+
#if swift(>=5.2)
58+
if #available(iOS 14.0, *) {
59+
#if swift(>=5.3) && !(os(OSX) || (os(iOS) && targetEnvironment(macCatalyst)))
60+
datePicker.preferredDatePickerStyle = .inline
61+
#else
62+
datePicker.preferredDatePickerStyle = .wheels
63+
#endif
64+
} else if #available(iOS 13.4, *) {
65+
datePicker.preferredDatePickerStyle = .wheels
66+
}
67+
#endif
5668
}
5769

5870
deinit {

0 commit comments

Comments
 (0)