diff --git a/Pickers/ActionSheetDatePicker.h b/Pickers/ActionSheetDatePicker.h index d64a69a2e..b4c224fe4 100755 --- a/Pickers/ActionSheetDatePicker.h +++ b/Pickers/ActionSheetDatePicker.h @@ -48,31 +48,45 @@ typedef void(^ActionDateCancelBlock)(ActionSheetDatePicker *picker); @property (nonatomic, copy) ActionDateDoneBlock onActionSheetDone; @property (nonatomic, copy) ActionDateCancelBlock onActionSheetCancel; -+ (instancetype)showPickerWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate target:(id)target action:(SEL)action origin:(id)origin; - -+ (instancetype)showPickerWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate target:(id)target action:(SEL)action origin:(id)origin cancelAction:(SEL)cancelAction; ++ (instancetype)showPickerWithTitle:(NSString *)title + datePickerMode:(UIDatePickerMode)datePickerMode + selectedDate:(NSDate *)selectedDate + target:(id)target + action:(SEL)action + origin:(id)origin; + (instancetype)showPickerWithTitle:(NSString *)title - datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate - minimumDate:(NSDate *)minimumDate maximumDate:(NSDate *)maximumDate - target:(id)target action:(SEL)action origin:(id)origin; + datePickerMode:(UIDatePickerMode)datePickerMode + selectedDate:(NSDate *)selectedDate + target:(id)target + action:(SEL)action + origin:(id)origin + cancelAction:(SEL)cancelAction; + (instancetype)showPickerWithTitle:(NSString *)title - datePickerMode:(UIDatePickerMode)datePickerMode - selectedDate:(NSDate *)selectedDate - doneBlock:(ActionDateDoneBlock)doneBlock - cancelBlock:(ActionDateCancelBlock)cancelBlock - origin:(UIView*)view; + datePickerMode:(UIDatePickerMode)datePickerMode + selectedDate:(NSDate *)selectedDate + minimumDate:(NSDate *)minimumDate + maximumDate:(NSDate *)maximumDate + target:(id)target + action:(SEL)action + origin:(id)origin; + (instancetype)showPickerWithTitle:(NSString *)title - datePickerMode:(UIDatePickerMode)datePickerMode - selectedDate:(NSDate *)selectedDate - minimumDate:(NSDate *)minimumDate - maximumDate:(NSDate *)maximumDate - doneBlock:(ActionDateDoneBlock)doneBlock - cancelBlock:(ActionDateCancelBlock)cancelBlock - origin:(UIView*)view; + datePickerMode:(UIDatePickerMode)datePickerMode + selectedDate:(NSDate *)selectedDate + doneBlock:(ActionDateDoneBlock)doneBlock + cancelBlock:(ActionDateCancelBlock)cancelBlock + origin:(UIView*)view; ++ (instancetype)showPickerWithTitle:(NSString *)title + datePickerMode:(UIDatePickerMode)datePickerMode + selectedDate:(NSDate *)selectedDate + minimumDate:(NSDate *)minimumDate + maximumDate:(NSDate *)maximumDate + doneBlock:(ActionDateDoneBlock)doneBlock + cancelBlock:(ActionDateCancelBlock)cancelBlock + origin:(UIView*)view; - (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate target:(id)target action:(SEL)action origin:(id)origin; diff --git a/Pickers/ActionSheetDatePicker.m b/Pickers/ActionSheetDatePicker.m index 3b92237ff..66209a5c1 100755 --- a/Pickers/ActionSheetDatePicker.m +++ b/Pickers/ActionSheetDatePicker.m @@ -30,8 +30,11 @@ #import @interface ActionSheetDatePicker() + @property (nonatomic, assign) UIDatePickerMode datePickerMode; @property (nonatomic, strong) NSDate *selectedDate; +@property (nonatomic, assign) UIDatePickerStyle datePickerStyle API_AVAILABLE(ios(13.4)); + @end @implementation ActionSheetDatePicker @@ -147,6 +150,9 @@ - (instancetype)initWithTitle:(NSString *)title origin:(UIView*)origin { self = [self initWithTitle:title datePickerMode:datePickerMode selectedDate:selectedDate target:nil action:nil origin:origin]; + if (@available(iOS 13.4, *)) { + self.datePickerStyle = UIDatePickerStyleAutomatic; + } if (self) { self.onActionSheetDone = doneBlock; self.onActionSheetCancel = cancelBlock; @@ -164,10 +170,13 @@ - (UIView *)configuredPickerView { datePicker.calendar = self.calendar; datePicker.timeZone = self.timeZone; datePicker.locale = self.locale; - - UIColor *textColor = [self.pickerTextAttributes valueForKey:NSForegroundColorAttributeName]; - if (textColor) { - [datePicker setValue:textColor forKey:@"textColor"]; // use ObjC runtime to set value for property that is not exposed publicly + if (@available(iOS 13.4, *)) { + datePicker.preferredDatePickerStyle = self.datePickerStyle; + } else { + UIColor *textColor = [self.pickerTextAttributes valueForKey:NSForegroundColorAttributeName]; + if (textColor) { + [datePicker setValue:textColor forKey:@"textColor"]; // use ObjC runtime to set value for property that is not exposed publicly + } } // if datepicker is set with a date in countDownMode then