Commit d6d6a6e9 authored by yuzheng.tz's avatar yuzheng.tz

优化isIPhoneX方法,iPhone10,6是美版iPhoneX

parent 08b39be0
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
@interface TZCommonTools : NSObject @interface TZCommonTools : NSObject
+ (BOOL)isIPhoneX; + (BOOL)tz_isIPhoneX;
+ (CGFloat)statusBarHeight; + (CGFloat)tz_statusBarHeight;
@end @end
...@@ -642,7 +642,7 @@ ...@@ -642,7 +642,7 @@
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden; BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
if (self.navigationController.navigationBar.isTranslucent) { if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight; top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools statusBarHeight]; if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools tz_statusBarHeight];
tableViewHeight = self.view.tz_height - top; tableViewHeight = self.view.tz_height - top;
} else { } else {
tableViewHeight = self.view.tz_height; tableViewHeight = self.view.tz_height;
...@@ -713,7 +713,7 @@ ...@@ -713,7 +713,7 @@
@implementation TZCommonTools @implementation TZCommonTools
+ (BOOL)isIPhoneX { + (BOOL)tz_isIPhoneX {
struct utsname systemInfo; struct utsname systemInfo;
uname(&systemInfo); uname(&systemInfo);
NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding]; NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
...@@ -721,12 +721,13 @@ ...@@ -721,12 +721,13 @@
// 模拟器下采用屏幕的高度来判断 // 模拟器下采用屏幕的高度来判断
return [UIScreen mainScreen].bounds.size.height == 812; return [UIScreen mainScreen].bounds.size.height == 812;
} }
BOOL isIPhoneX = [platform isEqualToString:@"iPhone10,3"]; // iPhone10,6是美版iPhoneX 感谢hegelsu指出:https://github.com/banchichen/TZImagePickerController/issues/635
BOOL isIPhoneX = [platform isEqualToString:@"iPhone10,3"] || [platform isEqualToString:@"iPhone10,6"];
return isIPhoneX; return isIPhoneX;
} }
+ (CGFloat)statusBarHeight { + (CGFloat)tz_statusBarHeight {
return [self isIPhoneX] ? 44 : 20; return [self tz_isIPhoneX] ? 44 : 20;
} }
@end @end
...@@ -266,10 +266,10 @@ static CGFloat itemMargin = 5; ...@@ -266,10 +266,10 @@ static CGFloat itemMargin = 5;
CGFloat collectionViewHeight = 0; CGFloat collectionViewHeight = 0;
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height; CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden; BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
CGFloat toolBarHeight = [TZCommonTools isIPhoneX] ? 50 + (83 - 49) : 50; CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 50 + (83 - 49) : 50;
if (self.navigationController.navigationBar.isTranslucent) { if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight; top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools statusBarHeight]; if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools tz_statusBarHeight];
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight - top : self.view.tz_height - top;; collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight - top : self.view.tz_height - top;;
} else { } else {
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight : self.view.tz_height; collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight : self.view.tz_height;
...@@ -290,7 +290,7 @@ static CGFloat itemMargin = 5; ...@@ -290,7 +290,7 @@ static CGFloat itemMargin = 5;
toolBarTop = self.view.tz_height - toolBarHeight; toolBarTop = self.view.tz_height - toolBarHeight;
} else { } else {
CGFloat navigationHeight = naviBarHeight; CGFloat navigationHeight = naviBarHeight;
if (iOS7Later) navigationHeight += [TZCommonTools statusBarHeight]; if (iOS7Later) navigationHeight += [TZCommonTools tz_statusBarHeight];
toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight; toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight;
} }
_bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight); _bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
......
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
CGFloat statusBarHeight = [TZCommonTools statusBarHeight]; CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight];
CGFloat statusBarHeightInterval = statusBarHeight - 20; CGFloat statusBarHeightInterval = statusBarHeight - 20;
CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar.tz_height; CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar.tz_height;
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, naviBarHeight); _naviBar.frame = CGRectMake(0, 0, self.view.tz_width, naviBarHeight);
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
[_collectionView reloadData]; [_collectionView reloadData];
} }
CGFloat toolBarHeight = [TZCommonTools isIPhoneX] ? 44 + (83 - 49) : 44; CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44;
CGFloat toolBarTop = self.view.tz_height - toolBarHeight; CGFloat toolBarTop = self.view.tz_height - toolBarHeight;
_toolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight); _toolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
if (_tzImagePickerVc.allowPickingOriginalPhoto) { if (_tzImagePickerVc.allowPickingOriginalPhoto) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment