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

适配iPhoneX,发布1.9.4版本

parent 7773696a
Pod::Spec.new do |s|
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.homepage = "https://github.com/banchichen/TZImagePickerController"
s.license = "MIT"
s.author = { "banchichen" => "tanzhenios@foxmail.com" }
s.platform = :ios
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.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.9.3</string>
<string>1.9.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -4,7 +4,7 @@
//
// Created by 谭真 on 15/12/24.
// 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
/*
......@@ -235,3 +235,9 @@
- (BOOL)tz_containsString:(NSString *)string;
@end
@interface TZCommonTools : NSObject
+ (BOOL)isIPhoneX;
+ (CGFloat)statusBarHeight;
@end
......@@ -4,7 +4,7 @@
//
// Created by 谭真 on 15/12/24.
// 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
#import "TZImagePickerController.h"
......@@ -14,6 +14,8 @@
#import "TZAssetCell.h"
#import "UIView+Layout.h"
#import "TZImageManager.h"
#import "math.h"
#import "sys/utsname.h"
@interface TZImagePickerController () {
NSTimer *_timer;
......@@ -640,7 +642,7 @@
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += 20;
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools statusBarHeight];
tableViewHeight = self.view.tz_height - top;
} else {
tableViewHeight = self.view.tz_height;
......@@ -707,3 +709,24 @@
}
@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;
[_bottomToolBar addSubview:_doneButton];
[_bottomToolBar addSubview:_numberImageView];
[_bottomToolBar addSubview:_numberLabel];
[_bottomToolBar addSubview:_originalPhotoButton];
[self.view addSubview:_bottomToolBar];
[self.view addSubview:_originalPhotoButton];
[_originalPhotoButton addSubview:_originalPhotoLabel];
}
......@@ -266,12 +266,13 @@ 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;
if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += 20;
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - 50 - top : self.view.tz_height - top;;
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools statusBarHeight];
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight - top : self.view.tz_height - top;;
} 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);
CGFloat itemWH = (self.view.tz_width - (self.columnNumber + 1) * itemMargin) / self.columnNumber;
......@@ -284,15 +285,15 @@ static CGFloat itemMargin = 5;
[_collectionView setContentOffset:CGPointMake(0, offsetY)];
}
CGFloat yOffset = 0;
CGFloat toolBarTop = 0;
if (!self.navigationController.navigationBar.isHidden) {
yOffset = self.view.tz_height - 50;
toolBarTop = self.view.tz_height - toolBarHeight;
} else {
CGFloat navigationHeight = naviBarHeight;
if (iOS7Later) navigationHeight += 20;
yOffset = self.view.tz_height - 50 - navigationHeight;
if (iOS7Later) navigationHeight += [TZCommonTools statusBarHeight];
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;
if (!tzImagePickerVc.allowPreview) {
previewWidth = 0.0;
......@@ -301,7 +302,7 @@ static CGFloat itemMargin = 5;
_previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth;
if (tzImagePickerVc.allowPickingOriginalPhoto) {
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);
}
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 3, 44, 44);
......
......@@ -217,9 +217,12 @@
[super viewDidLayoutSubviews];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, 64);
_backButton.frame = CGRectMake(10, 10, 44, 44);
_selectButton.frame = CGRectMake(self.view.tz_width - 54, 10, 42, 42);
CGFloat statusBarHeight = [TZCommonTools statusBarHeight];
CGFloat statusBarHeightInterval = statusBarHeight - 20;
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.minimumInteritemSpacing = 0;
......@@ -234,7 +237,9 @@
[_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) {
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);
......
......@@ -281,7 +281,7 @@
/*
[imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
[leftButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
[leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -20, 0, 20)];
[leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 20)];
}];
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