本文主要是介绍iOS14 UIDatePicker 样式变化恢复,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.原因:
新增了一个 preferredDatePickerStyle 导致的默认UI样式变化
/// Request a style for the date picker. If the style changed, then the date picker may need to be resized and will generate a layout pass to display correctly.
@property (nonatomic, readwrite, assign) UIDatePickerStyle preferredDatePickerStyle API_AVAILABLE(ios(13.4)) API_UNAVAILABLE(tvos, watchos);
2.恢复
if (@available(iOS 14.0, *)) {self.datePicker.preferredDatePickerStyle = UIDatePickerStyleWheels;//此处记得再写一下frame, 在datePickerMode设置之后self.datePicker.frame = CGRectMake(0, 50, 290, 160);
}
这篇关于iOS14 UIDatePicker 样式变化恢复的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!