Xcode12 在iOS14上 UIDatePicker显示不对

self.datePicker = [[UIDatePicker alloc] init];//WithFrame:CGRectMake(0, CGRectGetMaxY(self.topBackView.frame)+8, kScreenW, self.height-(CGRectGetMaxY(self.topBackView.frame)+8))];
[self addSubview:self.datePicker];
if (@available(iOS 13.4, *)) {
self.datePicker.preferredDatePickerStyle = UIDatePickerStyleWheels;
} else {
// Fallback on earlier versions
}
self.datePicker.datePickerMode = UIDatePickerModeDate;
self.datePicker.frame = CGRectMake(0, CGRectGetMaxY(self.topBackView.frame)+8, kScreenW, self.height-(CGRectGetMaxY(self.topBackView.frame)+8));
[self.datePicker setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_Hans_CN"]];
self.datePicker.maximumDate = [NSDate date];
self.datePicker.minimumDate = minDate;
frame设置要放在datePickerMode后,datePickerMode要放在preferredDatePickerStyle,要不然UI会有问题,

你可能感兴趣的:(Xcode12 在iOS14上 UIDatePicker显示不对)