Commit 08b39be0 authored by yuzheng.tz's avatar yuzheng.tz

适配iPhoneX,发布1.9.4版本

parent 7773696a
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "TZImagePickerController" s.name = "TZImagePickerController"
s.version = "1.9.3" s.version = "1.9.4"
s.summary = "A clone of UIImagePickerController, support picking multiple photos、original photo and video" s.summary = "A clone of UIImagePickerController, support picking multiple photos、original photo and video"
s.homepage = "https://github.com/banchichen/TZImagePickerController" s.homepage = "https://github.com/banchichen/TZImagePickerController"
s.license = "MIT" s.license = "MIT"
s.author = { "banchichen" => "tanzhenios@foxmail.com" } s.author = { "banchichen" => "tanzhenios@foxmail.com" }
s.platform = :ios s.platform = :ios
s.ios.deployment_target = "6.0" s.ios.deployment_target = "6.0"
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "1.9.3" } s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "1.9.4" }
s.requires_arc = true s.requires_arc = true
s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}" s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}" s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.9.3</string> <string>1.9.4</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// //
// Created by 谭真 on 15/12/24. // Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved. // Copyright © 2015年 谭真. All rights reserved.
// version 1.9.3 - 2017.09.13 // version 1.9.4 - 2017.11.08
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController // 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
/* /*
...@@ -235,3 +235,9 @@ ...@@ -235,3 +235,9 @@
- (BOOL)tz_containsString:(NSString *)string; - (BOOL)tz_containsString:(NSString *)string;
@end @end
@interface TZCommonTools : NSObject
+ (BOOL)isIPhoneX;
+ (CGFloat)statusBarHeight;
@end
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// //
// Created by 谭真 on 15/12/24. // Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved. // Copyright © 2015年 谭真. All rights reserved.
// version 1.9.3 - 2017.09.13 // version 1.9.4 - 2017.11.08
// 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController // 更多信息,请前往项目的github地址:https://github.com/banchichen/TZImagePickerController
#import "TZImagePickerController.h" #import "TZImagePickerController.h"
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#import "TZAssetCell.h" #import "TZAssetCell.h"
#import "UIView+Layout.h" #import "UIView+Layout.h"
#import "TZImageManager.h" #import "TZImageManager.h"
#import "math.h"
#import "sys/utsname.h"
@interface TZImagePickerController () { @interface TZImagePickerController () {
NSTimer *_timer; NSTimer *_timer;
...@@ -640,7 +642,7 @@ ...@@ -640,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 += 20; if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools 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;
...@@ -707,3 +709,24 @@ ...@@ -707,3 +709,24 @@
} }
@end @end
@implementation TZCommonTools
+ (BOOL)isIPhoneX {
struct utsname systemInfo;
uname(&systemInfo);
NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
if ([platform isEqualToString:@"i386"] || [platform isEqualToString:@"x86_64"]) {
// 模拟器下采用屏幕的高度来判断
return [UIScreen mainScreen].bounds.size.height == 812;
}
BOOL isIPhoneX = [platform isEqualToString:@"iPhone10,3"];
return isIPhoneX;
}
+ (CGFloat)statusBarHeight {
return [self isIPhoneX] ? 44 : 20;
}
@end
...@@ -250,8 +250,8 @@ static CGFloat itemMargin = 5; ...@@ -250,8 +250,8 @@ static CGFloat itemMargin = 5;
[_bottomToolBar addSubview:_doneButton]; [_bottomToolBar addSubview:_doneButton];
[_bottomToolBar addSubview:_numberImageView]; [_bottomToolBar addSubview:_numberImageView];
[_bottomToolBar addSubview:_numberLabel]; [_bottomToolBar addSubview:_numberLabel];
[_bottomToolBar addSubview:_originalPhotoButton];
[self.view addSubview:_bottomToolBar]; [self.view addSubview:_bottomToolBar];
[self.view addSubview:_originalPhotoButton];
[_originalPhotoButton addSubview:_originalPhotoLabel]; [_originalPhotoButton addSubview:_originalPhotoLabel];
} }
...@@ -266,12 +266,13 @@ static CGFloat itemMargin = 5; ...@@ -266,12 +266,13 @@ 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;
if (self.navigationController.navigationBar.isTranslucent) { if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight; top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += 20; if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools statusBarHeight];
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - 50 - 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 - 50 : self.view.tz_height; collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight : self.view.tz_height;
} }
_collectionView.frame = CGRectMake(0, top, self.view.tz_width, collectionViewHeight); _collectionView.frame = CGRectMake(0, top, self.view.tz_width, collectionViewHeight);
CGFloat itemWH = (self.view.tz_width - (self.columnNumber + 1) * itemMargin) / self.columnNumber; CGFloat itemWH = (self.view.tz_width - (self.columnNumber + 1) * itemMargin) / self.columnNumber;
...@@ -284,15 +285,15 @@ static CGFloat itemMargin = 5; ...@@ -284,15 +285,15 @@ static CGFloat itemMargin = 5;
[_collectionView setContentOffset:CGPointMake(0, offsetY)]; [_collectionView setContentOffset:CGPointMake(0, offsetY)];
} }
CGFloat yOffset = 0; CGFloat toolBarTop = 0;
if (!self.navigationController.navigationBar.isHidden) { if (!self.navigationController.navigationBar.isHidden) {
yOffset = self.view.tz_height - 50; toolBarTop = self.view.tz_height - toolBarHeight;
} else { } else {
CGFloat navigationHeight = naviBarHeight; CGFloat navigationHeight = naviBarHeight;
if (iOS7Later) navigationHeight += 20; if (iOS7Later) navigationHeight += [TZCommonTools statusBarHeight];
yOffset = self.view.tz_height - 50 - navigationHeight; toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight;
} }
_bottomToolBar.frame = CGRectMake(0, yOffset, self.view.tz_width, 50); _bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.width + 2; CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.width + 2;
if (!tzImagePickerVc.allowPreview) { if (!tzImagePickerVc.allowPreview) {
previewWidth = 0.0; previewWidth = 0.0;
...@@ -301,7 +302,7 @@ static CGFloat itemMargin = 5; ...@@ -301,7 +302,7 @@ static CGFloat itemMargin = 5;
_previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth; _previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth;
if (tzImagePickerVc.allowPickingOriginalPhoto) { if (tzImagePickerVc.allowPickingOriginalPhoto) {
CGFloat fullImageWidth = [tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width; CGFloat fullImageWidth = [tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
_originalPhotoButton.frame = CGRectMake(CGRectGetMaxX(_previewButton.frame), self.view.tz_height - 50, fullImageWidth + 56, 50); _originalPhotoButton.frame = CGRectMake(CGRectGetMaxX(_previewButton.frame), 0, fullImageWidth + 56, 50);
_originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50); _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50);
} }
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 3, 44, 44); _doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 3, 44, 44);
......
...@@ -217,9 +217,12 @@ ...@@ -217,9 +217,12 @@
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, 64); CGFloat statusBarHeight = [TZCommonTools statusBarHeight];
_backButton.frame = CGRectMake(10, 10, 44, 44); CGFloat statusBarHeightInterval = statusBarHeight - 20;
_selectButton.frame = CGRectMake(self.view.tz_width - 54, 10, 42, 42); CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar.tz_height;
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, naviBarHeight);
_backButton.frame = CGRectMake(10, 10 + statusBarHeightInterval, 44, 44);
_selectButton.frame = CGRectMake(self.view.tz_width - 54, 10 + statusBarHeightInterval, 42, 42);
_layout.itemSize = CGSizeMake(self.view.tz_width + 20, self.view.tz_height); _layout.itemSize = CGSizeMake(self.view.tz_width + 20, self.view.tz_height);
_layout.minimumInteritemSpacing = 0; _layout.minimumInteritemSpacing = 0;
...@@ -234,7 +237,9 @@ ...@@ -234,7 +237,9 @@
[_collectionView reloadData]; [_collectionView reloadData];
} }
_toolBar.frame = CGRectMake(0, self.view.tz_height - 44, self.view.tz_width, 44); CGFloat toolBarHeight = [TZCommonTools 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) { if (_tzImagePickerVc.allowPickingOriginalPhoto) {
CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width; CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
_originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44); _originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44);
......
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
/* /*
[imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){ [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
[leftButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; [leftButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
[leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -20, 0, 20)]; [leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 20)];
}]; }];
imagePickerVc.delegate = self; imagePickerVc.delegate = self;
*/ */
......
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