Skip to content

Commit bc9d93e

Browse files
author
谭真
authored
Merge pull request #1161 from RayJiang16/master
修复 iOS 13 新的 present 效果导致 UI 错误的问题
2 parents aa51907 + 836e6dc commit bc9d93e

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ @interface TZImagePickerController () {
2121
UIButton *_settingBtn;
2222
BOOL _pushPhotoPickerVc;
2323
BOOL _didPushPhotoPickerVc;
24+
CGRect _cropRect;
2425

2526
UIButton *_progressHUD;
2627
UIView *_HUDContainer;
@@ -493,6 +494,18 @@ - (void)setCropRect:(CGRect)cropRect {
493494
_cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, cropRect.origin.x, widthHeight, widthHeight);
494495
}
495496

497+
- (CGRect)cropRect {
498+
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
499+
BOOL isFullScreen = self.view.tz_height == screenHeight;
500+
if (isFullScreen) {
501+
return _cropRect;
502+
} else {
503+
CGRect newCropRect = _cropRect;
504+
newCropRect.origin.y -= ((screenHeight - self.view.tz_height) / 2);
505+
return newCropRect;
506+
}
507+
}
508+
496509
- (void)setTimeout:(NSInteger)timeout {
497510
_timeout = timeout;
498511
if (timeout < 5) {
@@ -782,9 +795,10 @@ - (void)viewDidLayoutSubviews {
782795
CGFloat tableViewHeight = 0;
783796
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
784797
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
798+
BOOL isFullScreen = self.view.tz_height == [UIScreen mainScreen].bounds.size.height;
785799
if (self.navigationController.navigationBar.isTranslucent) {
786800
top = naviBarHeight;
787-
if (!isStatusBarHidden) top += [TZCommonTools tz_statusBarHeight];
801+
if (!isStatusBarHidden && isFullScreen) top += [TZCommonTools tz_statusBarHeight];
788802
tableViewHeight = self.view.tz_height - top;
789803
} else {
790804
tableViewHeight = self.view.tz_height;

TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,11 @@ - (void)viewDidLayoutSubviews {
303303
CGFloat collectionViewHeight = 0;
304304
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
305305
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
306+
BOOL isFullScreen = self.view.tz_height == [UIScreen mainScreen].bounds.size.height;
306307
CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 50 + (83 - 49) : 50;
307308
if (self.navigationController.navigationBar.isTranslucent) {
308309
top = naviBarHeight;
309-
if (!isStatusBarHidden) top += [TZCommonTools tz_statusBarHeight];
310+
if (!isStatusBarHidden && isFullScreen) top += [TZCommonTools tz_statusBarHeight];
310311
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight - top : self.view.tz_height - top;;
311312
} else {
312313
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight : self.view.tz_height;

TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ - (void)viewDidLayoutSubviews {
247247
[super viewDidLayoutSubviews];
248248
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
249249

250-
CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight];
251-
CGFloat statusBarHeightInterval = statusBarHeight - 20;
250+
BOOL isFullScreen = self.view.tz_height == [UIScreen mainScreen].bounds.size.height;
251+
CGFloat statusBarHeight = isFullScreen ? [TZCommonTools tz_statusBarHeight] : 0;
252+
CGFloat statusBarHeightInterval = isFullScreen ? (statusBarHeight - 20) : 0;
252253
CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar.tz_height;
253254
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, naviBarHeight);
254255
_backButton.frame = CGRectMake(10, 10 + statusBarHeightInterval, 44, 44);

TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ - (UIStatusBarStyle)preferredStatusBarStyle {
140140
- (void)viewDidLayoutSubviews {
141141
[super viewDidLayoutSubviews];
142142

143-
CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight];
143+
BOOL isFullScreen = self.view.tz_height == [UIScreen mainScreen].bounds.size.height;
144+
CGFloat statusBarHeight = isFullScreen ? [TZCommonTools tz_statusBarHeight] : 0;
144145
CGFloat statusBarAndNaviBarHeight = statusBarHeight + self.navigationController.navigationBar.tz_height;
145146
_playerLayer.frame = self.view.bounds;
146147
CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44;

0 commit comments

Comments
 (0)