Skip to content

Commit 4b41afa

Browse files
author
Gdxy
committed
UI细节优化
1 parent f003498 commit 4b41afa

4 files changed

+15
-9
lines changed

TLDatePicker/TLDatePicker.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ - (void)viewDidLayoutSubviews {
118118
frame.size.height = 50;
119119
self.topBar.frame = frame;
120120

121-
// rect.size.height = 50;
122-
// rect.origin.y = 50;
121+
rect.origin.y = self.isIPhoneXOrLater ? 25 : 10;
123122
self.datePicker.frame = rect;
124123

125124
[self.view bringSubviewToFront:self.topBar];

TLDatePicker/TLDatePickerBaseController.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

13-
#define kHeight 320.f // 竖屏
13+
#define kHeight 270.f // 竖屏
1414
#define kHeightOfLandscape 270.f // 横屏
1515

1616
@interface TLDatePickerBaseController : UIViewController
1717

18-
/// Picker View 的有效高度,iPhoneX系列 自动增加34。 默认: kHeight
18+
/// Picker View 的有效高度,默认: kHeight (非iPhone X系列 额外增加30 )
1919
@property(nonatomic, assign) CGFloat height;
2020

2121
@property(nonatomic, assign) BOOL disableTapMaskToDismiss;
2222
@property(nonatomic, copy) void (^didTapMaskView)(void);
2323

24+
@property(nonatomic, assign, readonly) BOOL isIPhoneXOrLater;
25+
2426
- (void)showInViewController:(UIViewController *)vc;
2527
@end
2628

TLDatePicker/TLDatePickerBaseController.m

+9-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ - (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection
3939
- (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
4040
BOOL isCompact = traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact;
4141
CGFloat H = isCompact ? kHeightOfLandscape : kHeight;
42-
BOOL isIPhoneX = YES;
43-
if (isIPhoneX) {
44-
H += 34;
42+
if (!self.isIPhoneXOrLater) {
43+
H += 30;
4544
}
4645
self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, H);
4746
}
@@ -59,5 +58,11 @@ - (void)showInViewController:(UIViewController *)vc {
5958
[vc presentViewController:self animated:YES completion:nil];
6059
}
6160

62-
61+
- (BOOL)isIPhoneXOrLater {
62+
BOOL isIPhoneX = (CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812)) ||
63+
CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(812, 375)) ||
64+
CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 896)) ||
65+
CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(896, 414)));
66+
return isIPhoneX;
67+
}
6368
@end

TLDatePicker/TLDatePickerView.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComp
196196
// 恢复到上次选中的item
197197
[cpt selectItemOfIndex:index];
198198
[self scrollToSelectedDateWithAnimatedComponent:cpt];
199-
[self showTip:@"无效选择,日期低于上限"];
199+
[self showTip:@"无效选择,日期小于下限"];
200200
return;
201201
}else if (self.maxDate && [self.maxDate compareFrom:willSelectDate] < 0) {
202202
// 无效选择,日期不能大于self.maxDate

0 commit comments

Comments
 (0)