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

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

parent 08b39be0
......@@ -237,7 +237,7 @@
@interface TZCommonTools : NSObject
+ (BOOL)isIPhoneX;
+ (CGFloat)statusBarHeight;
+ (BOOL)tz_isIPhoneX;
+ (CGFloat)tz_statusBarHeight;
@end
......@@ -642,7 +642,7 @@
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools statusBarHeight];
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools tz_statusBarHeight];
tableViewHeight = self.view.tz_height - top;
} else {
tableViewHeight = self.view.tz_height;
......@@ -713,7 +713,7 @@
@implementation TZCommonTools
+ (BOOL)isIPhoneX {
+ (BOOL)tz_isIPhoneX {
struct utsname systemInfo;
uname(&systemInfo);
NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
......@@ -721,12 +721,13 @@
// 模拟器下采用屏幕的高度来判断
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;
}
+ (CGFloat)statusBarHeight {
return [self isIPhoneX] ? 44 : 20;
+ (CGFloat)tz_statusBarHeight {
return [self tz_isIPhoneX] ? 44 : 20;
}
@end
......@@ -266,10 +266,10 @@ static CGFloat itemMargin = 5;
CGFloat collectionViewHeight = 0;
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
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) {
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;;
} else {
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight : self.view.tz_height;
......@@ -290,7 +290,7 @@ static CGFloat itemMargin = 5;
toolBarTop = self.view.tz_height - toolBarHeight;
} else {
CGFloat navigationHeight = naviBarHeight;
if (iOS7Later) navigationHeight += [TZCommonTools statusBarHeight];
if (iOS7Later) navigationHeight += [TZCommonTools tz_statusBarHeight];
toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight;
}
_bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
......
......@@ -217,7 +217,7 @@
[super viewDidLayoutSubviews];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
CGFloat statusBarHeight = [TZCommonTools statusBarHeight];
CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight];
CGFloat statusBarHeightInterval = statusBarHeight - 20;
CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar.tz_height;
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, naviBarHeight);
......@@ -237,7 +237,7 @@
[_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;
_toolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
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