diff --git a/TZImagePickerController.podspec b/TZImagePickerController.podspec index 59766a7e..3f739c19 100644 --- a/TZImagePickerController.podspec +++ b/TZImagePickerController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "TZImagePickerController" - s.version = "3.8.3" + s.version = "3.8.3.1" s.summary = "A clone of UIImagePickerController, support picking multiple photos、original photo and video" s.homepage = "https://github.com/banchichen/TZImagePickerController" s.license = "MIT" diff --git a/TZImagePickerController.xcodeproj/project.pbxproj b/TZImagePickerController.xcodeproj/project.pbxproj index 9e4a4efd..2ef8d777 100644 --- a/TZImagePickerController.xcodeproj/project.pbxproj +++ b/TZImagePickerController.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 47651C4429B9CDD900B16480 /* TZCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 47651C4329B9CDD900B16480 /* TZCollectionViewFlowLayout.m */; }; + 47651C4529B9CEBB00B16480 /* TZCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 47651C4329B9CDD900B16480 /* TZCollectionViewFlowLayout.m */; }; 570A348C26D7275C000EEF2E /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348B26D7275C000EEF2E /* Photos.framework */; }; 570A348E26D72762000EEF2E /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348D26D72762000EEF2E /* PhotosUI.framework */; }; 570A349026D72768000EEF2E /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348F26D72768000EEF2E /* PhotosUI.framework */; }; @@ -122,6 +124,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 47651C4229B9CDD900B16480 /* TZCollectionViewFlowLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TZCollectionViewFlowLayout.h; sourceTree = ""; }; + 47651C4329B9CDD900B16480 /* TZCollectionViewFlowLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TZCollectionViewFlowLayout.m; sourceTree = ""; }; 570A348B26D7275C000EEF2E /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Photos.framework; sourceTree = DEVELOPER_DIR; }; 570A348D26D72762000EEF2E /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/System/Library/Frameworks/PhotosUI.framework; sourceTree = DEVELOPER_DIR; }; 570A348F26D72768000EEF2E /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; @@ -369,6 +373,8 @@ 9005E2B1257A462E002A8682 /* UIView+TZLayout.m */, 6D5358CB1D64600F00928CC6 /* NSBundle+TZImagePicker.h */, 6D5358CC1D64600F00928CC6 /* NSBundle+TZImagePicker.m */, + 47651C4229B9CDD900B16480 /* TZCollectionViewFlowLayout.h */, + 47651C4329B9CDD900B16480 /* TZCollectionViewFlowLayout.m */, 6DC358641CC8BAE300898D29 /* Resources */, ); path = TZImagePickerController; @@ -631,6 +637,7 @@ B606A9C4265FD53200F5493E /* TZVideoCropController.m in Sources */, 901F2296215CABD600F604ED /* FLAnimatedImageView.m in Sources */, 9019FD8D21EC25D7009ADEAE /* TZImageUploadOperation.m in Sources */, + 47651C4429B9CDD900B16480 /* TZCollectionViewFlowLayout.m in Sources */, 900E65811C2BB8D5003D9A9E /* main.m in Sources */, 900EF0121C2C107400EA709B /* TZPhotoPreviewController.m in Sources */, 901CC3FC21CB758500C55443 /* TZImageRequestOperation.m in Sources */, @@ -674,6 +681,7 @@ 9F763A5C1FA072E500D9E526 /* TZVideoPlayerController.m in Sources */, 9F763A5E1FA072E500D9E526 /* TZGifPhotoPreviewController.m in Sources */, 9F763A601FA072E500D9E526 /* TZProgressView.m in Sources */, + 47651C4529B9CEBB00B16480 /* TZCollectionViewFlowLayout.m in Sources */, 908D11592887ED8000DD212E /* TZLocationManager.m in Sources */, 9F763A621FA072E500D9E526 /* TZImageManager.m in Sources */, 9F763A641FA072E500D9E526 /* TZImageCropManager.m in Sources */, @@ -852,7 +860,7 @@ INFOPLIST_FILE = TZImagePickerController/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 3.8.3; + MARKETING_VERSION = 3.8.3.1; PRODUCT_BUNDLE_IDENTIFIER = tanzhenios2022.TZImagePickerController.www; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; @@ -877,7 +885,7 @@ INFOPLIST_FILE = TZImagePickerController/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 3.8.3; + MARKETING_VERSION = 3.8.3.1; PRODUCT_BUNDLE_IDENTIFIER = tanzhenios2022.TZImagePickerController.www; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; diff --git a/TZImagePickerController/TZImagePickerController/TZAssetCell.h b/TZImagePickerController/TZImagePickerController/TZAssetCell.h index 67051e8f..4fe2fd56 100644 --- a/TZImagePickerController/TZImagePickerController/TZAssetCell.h +++ b/TZImagePickerController/TZImagePickerController/TZAssetCell.h @@ -44,7 +44,7 @@ typedef enum : NSUInteger { @class TZAlbumModel; @interface TZAlbumCell : UITableViewCell @property (nonatomic, strong) TZAlbumModel *model; -@property (weak, nonatomic) UIButton *selectedCountButton; +@property (strong, nonatomic) UIButton *selectedCountButton; @property (nonatomic, copy) void (^albumCellDidSetModelBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel); @property (nonatomic, copy) void (^albumCellDidLayoutSubviewsBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel); diff --git a/TZImagePickerController/TZImagePickerController/TZAssetCell.m b/TZImagePickerController/TZImagePickerController/TZAssetCell.m index bb23ef35..c08d3604 100644 --- a/TZImagePickerController/TZImagePickerController/TZAssetCell.m +++ b/TZImagePickerController/TZImagePickerController/TZAssetCell.m @@ -394,8 +394,8 @@ - (void)dealloc { @end @interface TZAlbumCell () -@property (weak, nonatomic) UIImageView *posterImageView; -@property (weak, nonatomic) UILabel *titleLabel; +@property (strong, nonatomic) UIImageView *posterImageView; +@property (strong, nonatomic) UILabel *titleLabel; @end @implementation TZAlbumCell @@ -404,9 +404,37 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; self.backgroundColor = [UIColor whiteColor]; self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + [self setupUI]; return self; } +- (void)setupUI{ + [self.contentView addSubview:self.posterImageView]; + NSLayoutConstraint *posterImage_left = [NSLayoutConstraint constraintWithItem:self.posterImageView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]; + NSLayoutConstraint *posterImage_centerY = [NSLayoutConstraint constraintWithItem:self.posterImageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + NSLayoutConstraint *posterImage_width = [NSLayoutConstraint constraintWithItem:self.posterImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:70]; + NSLayoutConstraint *posterImage_height = [NSLayoutConstraint constraintWithItem:self.posterImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:70]; + [self.contentView addConstraints:@[posterImage_left,posterImage_centerY]]; + [self.posterImageView addConstraints:@[posterImage_width,posterImage_height]]; + + + [self.contentView addSubview:self.titleLabel]; + NSLayoutConstraint *titleLabel_left = [NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.posterImageView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:10]; + NSLayoutConstraint *titleLabel_centerY = [NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.posterImageView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + NSLayoutConstraint *titleLabel_right = [NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-50]; + [self.contentView addConstraints:@[titleLabel_left,titleLabel_centerY,titleLabel_right]]; + + + [self.contentView addSubview:self.selectedCountButton]; + NSLayoutConstraint *selectedCountButton_centerY = [NSLayoutConstraint constraintWithItem:self.selectedCountButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.posterImageView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + NSLayoutConstraint *selectedCountButton_right = [NSLayoutConstraint constraintWithItem:self.selectedCountButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-5]; + NSLayoutConstraint *selectedCountButton_width = [NSLayoutConstraint constraintWithItem:self.selectedCountButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:24]; + NSLayoutConstraint *selectedCountButton_height = [NSLayoutConstraint constraintWithItem:self.selectedCountButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:24]; + [self.contentView addConstraints:@[selectedCountButton_centerY,selectedCountButton_right]]; + [self.selectedCountButton addConstraints:@[selectedCountButton_width,selectedCountButton_height]]; + +} + - (void)setModel:(TZAlbumModel *)model { _model = model; @@ -436,10 +464,6 @@ - (void)setModel:(TZAlbumModel *)model { - (void)layoutSubviews { [super layoutSubviews]; - _selectedCountButton.frame = CGRectMake(self.contentView.tz_width - 24, 23, 24, 24); - NSInteger titleHeight = ceil(self.titleLabel.font.lineHeight); - self.titleLabel.frame = CGRectMake(80, (self.tz_height - titleHeight) / 2, self.tz_width - 80 - 50, titleHeight); - self.posterImageView.frame = CGRectMake(0, 0, 70, 70); if (self.albumCellDidLayoutSubviewsBlock) { self.albumCellDidLayoutSubviewsBlock(self, _posterImageView, _titleLabel); @@ -457,7 +481,7 @@ - (UIImageView *)posterImageView { UIImageView *posterImageView = [[UIImageView alloc] init]; posterImageView.contentMode = UIViewContentModeScaleAspectFill; posterImageView.clipsToBounds = YES; - [self.contentView addSubview:posterImageView]; + posterImageView.translatesAutoresizingMaskIntoConstraints = NO; _posterImageView = posterImageView; } return _posterImageView; @@ -467,13 +491,13 @@ - (UILabel *)titleLabel { if (_titleLabel == nil) { UILabel *titleLabel = [[UILabel alloc] init]; titleLabel.font = [UIFont boldSystemFontOfSize:17]; + titleLabel.textAlignment = NSTextAlignmentNatural; + titleLabel.translatesAutoresizingMaskIntoConstraints = NO; if (@available(iOS 13.0, *)) { titleLabel.textColor = UIColor.labelColor; } else { titleLabel.textColor = [UIColor blackColor]; } - titleLabel.textAlignment = NSTextAlignmentLeft; - [self.contentView addSubview:titleLabel]; _titleLabel = titleLabel; } return _titleLabel; @@ -488,7 +512,7 @@ - (UIButton *)selectedCountButton { selectedCountButton.backgroundColor = [UIColor redColor]; [selectedCountButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; selectedCountButton.titleLabel.font = [UIFont systemFontOfSize:15]; - [self.contentView addSubview:selectedCountButton]; + selectedCountButton.translatesAutoresizingMaskIntoConstraints = NO; _selectedCountButton = selectedCountButton; } return _selectedCountButton; diff --git a/TZImagePickerController/TZImagePickerController/TZCollectionViewFlowLayout.h b/TZImagePickerController/TZImagePickerController/TZCollectionViewFlowLayout.h new file mode 100644 index 00000000..f3e397ed --- /dev/null +++ b/TZImagePickerController/TZImagePickerController/TZCollectionViewFlowLayout.h @@ -0,0 +1,17 @@ +// +// TZCollectionViewFlowLayout.h +// TZImagePickerController +// +// Created by Sir 姚 on 2023/3/9. +// Copyright © 2023 谭真. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface TZCollectionViewFlowLayout : UICollectionViewFlowLayout + +@end + +NS_ASSUME_NONNULL_END diff --git a/TZImagePickerController/TZImagePickerController/TZCollectionViewFlowLayout.m b/TZImagePickerController/TZImagePickerController/TZCollectionViewFlowLayout.m new file mode 100644 index 00000000..18729a47 --- /dev/null +++ b/TZImagePickerController/TZImagePickerController/TZCollectionViewFlowLayout.m @@ -0,0 +1,16 @@ +// +// TZCollectionViewFlowLayout.m +// TZImagePickerController +// +// Created by Sir 姚 on 2023/3/9. +// Copyright © 2023 谭真. All rights reserved. +// + +#import "TZCollectionViewFlowLayout.h" + +@implementation TZCollectionViewFlowLayout + +- (BOOL)flipsHorizontallyInOppositeLayoutDirection{ + return YES; +} +@end diff --git a/TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m b/TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m index 26c1a79a..6616a918 100644 --- a/TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m +++ b/TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m @@ -68,27 +68,31 @@ - (void)configPreviewView { } - (void)configBottomToolBar { - _toolBar = [[UIView alloc] initWithFrame:CGRectZero]; + _toolBar = [[UIView alloc] init]; + _toolBar.translatesAutoresizingMaskIntoConstraints = NO; CGFloat rgb = 34 / 255.0; _toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7]; _doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; + _doneButton.translatesAutoresizingMaskIntoConstraints = NO; [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside]; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; if (tzImagePickerVc) { [_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal]; [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal]; + _doneButton.titleLabel.font = tzImagePickerVc.doneBtnTitleFont; } else { [_doneButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal]; [_doneButton setTitleColor:[UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0] forState:UIControlStateNormal]; + _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; } [_toolBar addSubview:_doneButton]; UILabel *byteLabel = [[UILabel alloc] init]; byteLabel.textColor = [UIColor whiteColor]; + byteLabel.textAlignment = NSTextAlignmentNatural; byteLabel.font = [UIFont systemFontOfSize:13]; - byteLabel.frame = CGRectMake(10, 0, 100, 44); + byteLabel.translatesAutoresizingMaskIntoConstraints = NO; [[TZImageManager manager] getPhotosBytesWithArray:@[_model] completion:^(NSString *totalBytes) { byteLabel.text = totalBytes; }]; @@ -99,6 +103,27 @@ - (void)configBottomToolBar { if (tzImagePickerVc.gifPreviewPageUIConfigBlock) { tzImagePickerVc.gifPreviewPageUIConfigBlock(_toolBar, _doneButton); } + + CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44; + + NSLayoutConstraint *toolBar_left = [NSLayoutConstraint constraintWithItem:_toolBar attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]; + NSLayoutConstraint *toolBar_right = [NSLayoutConstraint constraintWithItem:_toolBar attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0]; + NSLayoutConstraint *toolBar_bottom = [NSLayoutConstraint constraintWithItem:_toolBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; + NSLayoutConstraint *toolBar_height = [NSLayoutConstraint constraintWithItem:_toolBar attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:toolBarHeight]; + [self.view addConstraints:@[toolBar_left,toolBar_right,toolBar_bottom]]; + [_toolBar addConstraints:@[toolBar_height]]; + + NSLayoutConstraint *doneButton_right = [NSLayoutConstraint constraintWithItem:_doneButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-12]; + NSLayoutConstraint *doneButton_top = [NSLayoutConstraint constraintWithItem:_doneButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + NSLayoutConstraint *doneButton_height = [NSLayoutConstraint constraintWithItem:_doneButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:44]; + [_toolBar addConstraints:@[doneButton_right,doneButton_top]]; + [_doneButton addConstraint:doneButton_height]; + + NSLayoutConstraint *byteLabel_left = [NSLayoutConstraint constraintWithItem:byteLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeLeading multiplier:1.0 constant:10]; + NSLayoutConstraint *byteLabel_top = [NSLayoutConstraint constraintWithItem:byteLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + NSLayoutConstraint *byteLabel_height = [NSLayoutConstraint constraintWithItem:byteLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:44]; + [_toolBar addConstraints:@[byteLabel_left,byteLabel_top]]; + [byteLabel addConstraints:@[byteLabel_height]]; } - (UIStatusBarStyle)preferredStatusBarStyle { @@ -116,10 +141,10 @@ - (void)viewDidLayoutSubviews { _previewView.frame = self.view.bounds; _previewView.scrollView.frame = self.view.bounds; - CGFloat toolBarHeight = 44 + [TZCommonTools tz_safeAreaInsets].bottom; - _toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight); - [_doneButton sizeToFit]; - _doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, MAX(44, _doneButton.tz_width), 44); +// CGFloat toolBarHeight = 44 + [TZCommonTools tz_safeAreaInsets].bottom; +// _toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight); +// [_doneButton sizeToFit]; +// _doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, MAX(44, _doneButton.tz_width), 44); TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; if (tzImagePickerVc.gifPreviewPageDidLayoutSubviewsBlock) { diff --git a/TZImagePickerController/TZImagePickerController/TZImageManager.m b/TZImagePickerController/TZImagePickerController/TZImageManager.m index 90e989ce..dc9b2d43 100755 --- a/TZImagePickerController/TZImagePickerController/TZImageManager.m +++ b/TZImagePickerController/TZImagePickerController/TZImageManager.m @@ -163,10 +163,12 @@ - (void)getAllAlbumsWithFetchAssets:(BOOL)needFetchAssets completion:(void (^)(N // 我的照片流 1.6.10重新加入.. PHFetchResult *myPhotoStreamAlbum = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumMyPhotoStream options:nil]; PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil]; - PHFetchResult *topLevelUserCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil]; +// PHFetchResult *topLevelUserCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil]; PHFetchResult *syncedAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumSyncedAlbum options:nil]; PHFetchResult *sharedAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumCloudShared options:nil]; - NSArray *allAlbums = @[myPhotoStreamAlbum,smartAlbums,topLevelUserCollections,syncedAlbums,sharedAlbums]; + // 用户的创建的文件夹相册 + PHFetchResult *userFolderAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil]; + NSArray *allAlbums = @[myPhotoStreamAlbum,smartAlbums,syncedAlbums,sharedAlbums,userFolderAlbums]; for (PHFetchResult *fetchResult in allAlbums) { for (PHAssetCollection *collection in fetchResult) { // 有可能是PHCollectionList类的的对象,过滤掉 diff --git a/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/ar.lproj/Localizable.strings b/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/ar.lproj/Localizable.strings index 7678b2b6..54955fda 100644 --- a/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/ar.lproj/Localizable.strings +++ b/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/ar.lproj/Localizable.strings @@ -18,7 +18,7 @@ "Can not choose both video and photo" = "لا يمكن اختيار كل من الفيديو والصور"; "Can not choose both photo and GIF" = "لا يمكن اختيار كل من الصور و GIF"; "Select the video when in multi state, we will handle the video as a photo" = "حدد مقطع الفيديو عندما يكون في حالة متعددة، وسنعمل على معالجة مقطع الفيديو كصورة"; -"Can not jump to the privacy settings page, please go to the settings page by self, thank you" = "إذا تعذّر الانتقال إلى صفحة "إعدادات الخصوصية"، فيرجى الانتقال إلى صفحة "الإعدادات" بنفسك، شكرًا لك"; +"Can not jump to the privacy settings page, please go to the settings page by self, thank you" = "إذا تعذّر الانتقال إلى صفحة إعدادات الخصوصية، فيرجى الانتقال إلى صفحة الإعدادات بنفسك، شكرًا لك"; "Select a maximum of %zd photos" = "حدد فقط ما يصل إلى %zd صورة"; "Select a minimum of %zd photos" = "الرجاء تحديد %zd صورة على الأقل"; "Allow %@ to access your album in \"Settings -> Privacy -> Photos\"" = "السماح لـ %@ بالوصول إلى الألبوم في \"الإعدادات > الخصوصية > الصور\""; diff --git a/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/tr.lproj/Localizable.strings b/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/tr.lproj/Localizable.strings new file mode 100644 index 00000000..165a9245 --- /dev/null +++ b/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/tr.lproj/Localizable.strings @@ -0,0 +1,20 @@ +"KEY" = "土耳其语"; +"OK" = "tamam"; +"Back" = "Geri"; +"Done" = "tamam"; +"Edit" = "Düzenle"; +"Sorry" = "Afedersiniz"; +"Cancel" = "İptal etmek"; +"Setting" = "Ayar"; +"Photos" = "Fotoğraflar"; +"Videos" = "Videolar"; +"Preview" = "Ön izleme"; +"Full image" = "Tam görüntü"; +"Processing..." = "İşleme..."; +"No Photos or Videos" = "Fotoğraf veya Video Yok"; +"Synchronizing photos from iCloud" = "Fotoğrafları iCloud'dan senkronize etme"; +"iCloud sync failed" = "iCloud senkronizasyon başarısız oldu"; +"Can not use camera" = "Kamera kullanılamaz"; +"Can not choose both video and photo" = "Hem video hem de fotoğraf seçilemiyor"; +"Can not choose both photo and GIF" = "Hem fotoğraf hem de GIF seçilemiyor"; +"Selected for %ld seconds" = "%ld saniye için seçildi"; diff --git a/TZImagePickerController/TZImagePickerController/TZImagePickerController.h b/TZImagePickerController/TZImagePickerController/TZImagePickerController.h index 7909a7e4..e3581a46 100644 --- a/TZImagePickerController/TZImagePickerController/TZImagePickerController.h +++ b/TZImagePickerController/TZImagePickerController/TZImagePickerController.h @@ -132,6 +132,7 @@ @property (nonatomic, copy) void(^uiImagePickerControllerSettingBlock)(UIImagePickerController *imagePickerController); /// 首选语言,如果设置了就用该语言,不设则取当前系统语言。 +/// 由于目前只支持中文、繁体中文、英文、越南语、阿拉伯。故该属性只支持zh-Hans、zh-Hant、en、vi、ar五种值,其余值无效。 /// 支持zh-Hans、zh-Hant、en、vi等值,详见TZImagePickerController.bundle内的语言资源 @property (copy, nonatomic) NSString *preferredLanguage; @@ -258,6 +259,11 @@ @property (nonatomic, strong) UIFont *naviTitleFont; @property (nonatomic, strong) UIColor *barItemTextColor; @property (nonatomic, strong) UIFont *barItemTextFont; +@property (nonatomic, strong) UIFont *doneBtnTitleFont; +@property (nonatomic, strong) UIFont *previewBtnTitleFont; +@property (nonatomic, strong) UIColor *viewBackgroundColor; // 控制器背景色 +@property (nonatomic, strong) UIColor *authorizationTipTextColor; // 授权提示文字颜色 +@property (nonatomic, strong) UIColor *authorizationSettingTextColor; // 授权跳转按钮文字颜色 @property (nonatomic, copy) NSString *doneBtnTitleStr; @property (nonatomic, copy) NSString *cancelBtnTitleStr; diff --git a/TZImagePickerController/TZImagePickerController/TZImagePickerController.m b/TZImagePickerController/TZImagePickerController/TZImagePickerController.m index 542144a7..88c71247 100644 --- a/TZImagePickerController/TZImagePickerController/TZImagePickerController.m +++ b/TZImagePickerController/TZImagePickerController/TZImagePickerController.m @@ -203,7 +203,7 @@ - (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount columnNumber:(N _tipLabel.textAlignment = NSTextAlignmentCenter; _tipLabel.numberOfLines = 0; _tipLabel.font = [UIFont systemFontOfSize:16]; - _tipLabel.textColor = [UIColor blackColor]; + _tipLabel.textColor = self.authorizationTipTextColor ? self.authorizationTipTextColor : [UIColor blackColor]; _tipLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; NSString *appName = [TZCommonTools tz_getAppName]; @@ -213,6 +213,9 @@ - (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount columnNumber:(N _settingBtn = [UIButton buttonWithType:UIButtonTypeSystem]; [_settingBtn setTitle:self.settingBtnTitleStr forState:UIControlStateNormal]; + if (self.authorizationSettingTextColor){ + [_settingBtn setTitleColor:self.authorizationSettingTextColor forState:UIControlStateNormal]; + } _settingBtn.frame = CGRectMake(0, 180, self.view.tz_width, 44); _settingBtn.titleLabel.font = [UIFont systemFontOfSize:18]; [_settingBtn addTarget:self action:@selector(settingBtnClick) forControlEvents:UIControlEventTouchUpInside]; @@ -296,6 +299,8 @@ - (void)configDefaultSetting { self.naviTitleColor = [UIColor whiteColor]; self.naviTitleFont = [UIFont systemFontOfSize:17]; self.barItemTextFont = [UIFont systemFontOfSize:15]; + self.doneBtnTitleFont = [UIFont systemFontOfSize:16]; + self.previewBtnTitleFont = [UIFont systemFontOfSize:16]; self.barItemTextColor = [UIColor whiteColor]; self.allowPreview = YES; // 2.2.26版本,不主动缩放图片,降低内存占用 @@ -766,16 +771,21 @@ - (void)viewDidLoad { [[PHPhotoLibrary sharedPhotoLibrary] registerChangeObserver:self]; } self.isFirstAppear = YES; - if (@available(iOS 13.0, *)) { - self.view.backgroundColor = UIColor.tertiarySystemBackgroundColor; - } else { - self.view.backgroundColor = [UIColor whiteColor]; - } TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController; UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithTitle:imagePickerVc.cancelBtnTitleStr style:UIBarButtonItemStylePlain target:imagePickerVc action:@selector(cancelButtonClick)]; [TZCommonTools configBarButtonItem:cancelItem tzImagePickerVc:imagePickerVc]; self.navigationItem.rightBarButtonItem = cancelItem; + + if (imagePickerVc.viewBackgroundColor){ + self.view.backgroundColor = imagePickerVc.viewBackgroundColor; + }else{ + if (@available(iOS 13.0, *)) { + self.view.backgroundColor = UIColor.tertiarySystemBackgroundColor; + } else { + self.view.backgroundColor = [UIColor whiteColor]; + } + } } - (void)viewWillAppear:(BOOL)animated { @@ -1072,7 +1082,7 @@ + (instancetype)sharedInstance { dispatch_once(&onceToken, ^{ if (config == nil) { config = [[TZImagePickerConfig alloc] init]; - config.supportedLanguages = [NSSet setWithObjects:@"zh-Hans", @"zh-Hant", @"en", @"ar", @"de", @"es", @"fr", @"ja", @"ko-KP", @"pt", @"ru", @"vi", nil]; + config.supportedLanguages = [NSSet setWithObjects:@"zh-Hans", @"zh-Hant", @"en", @"ar", @"de", @"es", @"fr", @"ja", @"ko-KP", @"pt", @"ru", @"vi",@"tr", nil]; config.preferredLanguage = nil; config.gifPreviewMaxImagesCount = 50; } @@ -1083,10 +1093,20 @@ + (instancetype)sharedInstance { - (void)setPreferredLanguage:(NSString *)preferredLanguage { _preferredLanguage = preferredLanguage; - if (!preferredLanguage || !preferredLanguage.length) { - preferredLanguage = [NSLocale preferredLanguages].firstObject; - } - +// if (!preferredLanguage || !preferredLanguage.length) { +// preferredLanguage = [NSLocale preferredLanguages].firstObject; +// } +// if ([preferredLanguage rangeOfString:@"zh-Hans"].location != NSNotFound) { +// preferredLanguage = @"zh-Hans"; +// } else if ([preferredLanguage rangeOfString:@"zh-Hant"].location != NSNotFound) { +// preferredLanguage = @"zh-Hant"; +// } else if ([preferredLanguage rangeOfString:@"vi"].location != NSNotFound) { +// preferredLanguage = @"vi"; +// } else if ([preferredLanguage rangeOfString:@"ar"].location != NSNotFound){ +// preferredLanguage = @"ar"; +// }else { +// preferredLanguage = @"en"; +// } NSString *usedLanguage = @"en"; for (NSString *language in self.supportedLanguages) { if ([preferredLanguage hasPrefix:language]) { diff --git a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m index bfdc65a3..66203b7d 100755 --- a/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m +++ b/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m @@ -88,10 +88,14 @@ - (void)viewDidLoad { TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; _isSelectOriginalPhoto = tzImagePickerVc.isSelectOriginalPhoto; _shouldScrollToBottom = YES; - if (@available(iOS 13.0, *)) { - self.view.backgroundColor = UIColor.tertiarySystemBackgroundColor; - } else { - self.view.backgroundColor = [UIColor whiteColor]; + if (tzImagePickerVc.viewBackgroundColor){ + self.view.backgroundColor = tzImagePickerVc.viewBackgroundColor; + }else{ + if (@available(iOS 13.0, *)) { + self.view.backgroundColor = UIColor.tertiarySystemBackgroundColor; + } else { + self.view.backgroundColor = [UIColor whiteColor]; + } } self.navigationItem.title = _model.name; UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithTitle:tzImagePickerVc.cancelBtnTitleStr style:UIBarButtonItemStylePlain target:tzImagePickerVc action:@selector(cancelButtonClick)]; @@ -244,7 +248,8 @@ - (void)configBottomToolBar { TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; if (!tzImagePickerVc.showSelectBtn) return; - _bottomToolBar = [[UIView alloc] initWithFrame:CGRectZero]; + _bottomToolBar = [[UIView alloc] init]; + _bottomToolBar.translatesAutoresizingMaskIntoConstraints = NO; CGFloat rgb = 253 / 255.0; if (@available(iOS 13.0, *)) { _bottomToolBar.backgroundColor = UIColor.tertiarySystemBackgroundColor; @@ -253,8 +258,9 @@ - (void)configBottomToolBar { } _previewButton = [UIButton buttonWithType:UIButtonTypeCustom]; + _previewButton.translatesAutoresizingMaskIntoConstraints = NO; [_previewButton addTarget:self action:@selector(previewButtonClick) forControlEvents:UIControlEventTouchUpInside]; - _previewButton.titleLabel.font = [UIFont systemFontOfSize:16]; + _previewButton.titleLabel.font = tzImagePickerVc.previewBtnTitleFont; [_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateNormal]; [_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateDisabled]; if (@available(iOS 13.0, *)) { @@ -267,6 +273,7 @@ - (void)configBottomToolBar { if (tzImagePickerVc.allowPickingOriginalPhoto) { _originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom]; + _originalPhotoButton.translatesAutoresizingMaskIntoConstraints = NO; _originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, [TZCommonTools tz_isRightToLeftLayout] ? 10 : -10, 0, 0); [_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside]; _originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:16]; @@ -286,7 +293,8 @@ - (void)configBottomToolBar { _originalPhotoButton.enabled = tzImagePickerVc.selectedModels.count > 0; _originalPhotoLabel = [[UILabel alloc] init]; - _originalPhotoLabel.textAlignment = NSTextAlignmentLeft; + _originalPhotoLabel.translatesAutoresizingMaskIntoConstraints = NO; + _originalPhotoLabel.textAlignment = NSTextAlignmentNatural; _originalPhotoLabel.font = [UIFont systemFontOfSize:16]; if (@available(iOS 13.0, *)) { _originalPhotoLabel.textColor = [UIColor labelColor]; @@ -297,7 +305,8 @@ - (void)configBottomToolBar { } _doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; + _doneButton.translatesAutoresizingMaskIntoConstraints = NO; + _doneButton.titleLabel.font = tzImagePickerVc.doneBtnTitleFont; [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal]; [_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateDisabled]; @@ -306,12 +315,14 @@ - (void)configBottomToolBar { _doneButton.enabled = tzImagePickerVc.selectedModels.count || tzImagePickerVc.alwaysEnableDoneBtn; _numberImageView = [[UIImageView alloc] initWithImage:tzImagePickerVc.photoNumberIconImage]; + _numberImageView.translatesAutoresizingMaskIntoConstraints = NO; _numberImageView.hidden = tzImagePickerVc.selectedModels.count <= 0; _numberImageView.clipsToBounds = YES; _numberImageView.contentMode = UIViewContentModeScaleAspectFit; _numberImageView.backgroundColor = [UIColor clearColor]; _numberLabel = [[UILabel alloc] init]; + _numberLabel.translatesAutoresizingMaskIntoConstraints = NO; _numberLabel.font = [UIFont systemFontOfSize:15]; _numberLabel.adjustsFontSizeToFitWidth = YES; _numberLabel.textColor = [UIColor whiteColor]; @@ -325,6 +336,7 @@ - (void)configBottomToolBar { [_numberLabel addGestureRecognizer:tapGesture]; _divideLine = [[UIView alloc] init]; + _divideLine.translatesAutoresizingMaskIntoConstraints = NO; CGFloat rgb2 = 222 / 255.0; if (@available(iOS 13.0, *)) { UIColor *divideLineDyColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trainCollection) { @@ -352,6 +364,8 @@ - (void)configBottomToolBar { if (tzImagePickerVc.photoPickerPageUIConfigBlock) { tzImagePickerVc.photoPickerPageUIConfigBlock(_collectionView, _bottomToolBar, _previewButton, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel, _divideLine); } + + [self configBottomToolBarLayout]; } #pragma mark - Layout @@ -389,44 +403,99 @@ - (void)viewDidLayoutSubviews { [_collectionView setContentOffset:CGPointMake(0, offsetY)]; } - CGFloat toolBarTop = 0; - if (!self.navigationController.navigationBar.isHidden) { - toolBarTop = self.view.tz_height - toolBarHeight; - } else { - CGFloat navigationHeight = naviBarHeight + [TZCommonTools tz_statusBarHeight]; - toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight; - } - _bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight); - if (_authFooterTipView) { - CGFloat footerTipViewY = _bottomToolBar ? toolBarTop - footerTipViewH : self.view.tz_height - footerTipViewH; - _authFooterTipView.frame = CGRectMake(0, footerTipViewY, self.view.tz_width, footerTipViewH);; - } - 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; - } - _previewButton.frame = CGRectMake(10, 3, previewWidth, 44); - _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), 0, fullImageWidth + 56, 50); - _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50); - } - [_doneButton sizeToFit]; - _doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, MAX(44, _doneButton.tz_width), 50); - _numberImageView.frame = CGRectMake(_doneButton.tz_left - 24 - 5, 13, 24, 24); - _numberLabel.frame = _numberImageView.frame; - _divideLine.frame = CGRectMake(0, 0, self.view.tz_width, 1); +// CGFloat toolBarTop = 0; +// if (!self.navigationController.navigationBar.isHidden) { +// toolBarTop = self.view.tz_height - toolBarHeight; +// } else { +// CGFloat navigationHeight = naviBarHeight + [TZCommonTools tz_statusBarHeight]; +// toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight; +// } +// _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; +// } +// _previewButton.frame = CGRectMake(10, 3, previewWidth, 44); +// _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), 0, fullImageWidth + 56, 50); +// _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50); +// } +// [_doneButton sizeToFit]; +// _doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, MAX(44, _doneButton.tz_width), 50); +// _numberImageView.frame = CGRectMake(_doneButton.tz_left - 24 - 5, 13, 24, 24); +// _numberLabel.frame = _numberImageView.frame; +// _divideLine.frame = CGRectMake(0, 0, self.view.tz_width, 1); [TZImageManager manager].columnNumber = [TZImageManager manager].columnNumber; [TZImageManager manager].photoWidth = tzImagePickerVc.photoWidth; - [self.collectionView reloadData]; if (tzImagePickerVc.photoPickerPageDidLayoutSubviewsBlock) { tzImagePickerVc.photoPickerPageDidLayoutSubviewsBlock(_collectionView, _bottomToolBar, _previewButton, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel, _divideLine); } } +- (void)configBottomToolBarLayout{ + TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; + 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), 0, fullImageWidth + 56, 50); + _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50); + + NSLayoutConstraint *originalPhotoButton_left = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_previewButton attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:2]; + NSLayoutConstraint *originalPhotoButton_top = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + NSLayoutConstraint *originalPhotoButton_width = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeWidth multiplier:1.0 constant:fullImageWidth + 56]; + NSLayoutConstraint *originalPhotoButton_height = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:50]; + [_bottomToolBar addConstraints:@[originalPhotoButton_left,originalPhotoButton_top]]; + [_originalPhotoButton addConstraints:@[originalPhotoButton_width,originalPhotoButton_height]]; + + NSLayoutConstraint *originalPhotoLabel_left = [NSLayoutConstraint constraintWithItem:_originalPhotoLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_originalPhotoButton attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-10]; + NSLayoutConstraint *originalPhotoLabel_centerY = [NSLayoutConstraint constraintWithItem:_originalPhotoLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_originalPhotoButton attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + [_bottomToolBar addConstraints:@[originalPhotoLabel_left,originalPhotoLabel_centerY]]; + } + + CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 50 + (83 - 49) : 50; + + NSLayoutConstraint *bottomToolBar_left = [NSLayoutConstraint constraintWithItem:_bottomToolBar attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]; + NSLayoutConstraint *bottomToolBar_width = [NSLayoutConstraint constraintWithItem:_bottomToolBar attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]; + NSLayoutConstraint *bottomToolBar_bottom = [NSLayoutConstraint constraintWithItem:_bottomToolBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; + NSLayoutConstraint *bottomToolBar_height = [NSLayoutConstraint constraintWithItem:_bottomToolBar attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:toolBarHeight]; + [self.view addConstraints:@[bottomToolBar_left,bottomToolBar_width,bottomToolBar_bottom]]; + [_bottomToolBar addConstraints:@[bottomToolBar_height]]; + + NSLayoutConstraint *previewButton_left = [NSLayoutConstraint constraintWithItem:_previewButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeLeading multiplier:1.0 constant:10]; + NSLayoutConstraint *previewButton_top = [NSLayoutConstraint constraintWithItem:_previewButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:3]; + NSLayoutConstraint *previewButton_height = [NSLayoutConstraint constraintWithItem:_previewButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:44]; + [_bottomToolBar addConstraints:@[previewButton_left,previewButton_top]]; + [_previewButton addConstraints:@[previewButton_height]]; + + + NSLayoutConstraint *doneButton_right = [NSLayoutConstraint constraintWithItem:_doneButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-12]; + NSLayoutConstraint *doneButton_top = [NSLayoutConstraint constraintWithItem:_doneButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:10]; + [_bottomToolBar addConstraints:@[doneButton_right,doneButton_top]]; + + NSLayoutConstraint *numberImage_right = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:_doneButton attribute:NSLayoutAttributeLeading multiplier:1.0 constant:-5]; + NSLayoutConstraint *numberImage_centerY = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_doneButton attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + NSLayoutConstraint *numberImage_width = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:24]; + NSLayoutConstraint *numberImage_height = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:24]; + [_bottomToolBar addConstraints:@[numberImage_right,numberImage_centerY]]; + [_numberImageView addConstraints:@[numberImage_width,numberImage_height]]; + + NSLayoutConstraint *numberLabel_centerX = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:_numberImageView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]; + NSLayoutConstraint *numberLabel_centerY = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_numberImageView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + [_bottomToolBar addConstraints:@[numberLabel_centerX,numberLabel_centerY]]; + + NSLayoutConstraint *divideLine_right = [NSLayoutConstraint constraintWithItem:_divideLine attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0]; + NSLayoutConstraint *divideLine_left = [NSLayoutConstraint constraintWithItem:_divideLine attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]; + NSLayoutConstraint *divideLine_top = [NSLayoutConstraint constraintWithItem:_divideLine attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_bottomToolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; + NSLayoutConstraint *divideLine_height = [NSLayoutConstraint constraintWithItem:_divideLine attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:1]; + [_bottomToolBar addConstraints:@[divideLine_right,divideLine_left,divideLine_top]]; + [_divideLine addConstraint:divideLine_height]; +} + + #pragma mark - Notification - (void)didChangeStatusBarOrientationNotification:(NSNotification *)noti { diff --git a/TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m b/TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m index 6b55cf7f..282660ee 100644 --- a/TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m +++ b/TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m @@ -13,10 +13,11 @@ #import "TZImagePickerController.h" #import "TZImageManager.h" #import "TZImageCropManager.h" +#import "TZCollectionViewFlowLayout.h" @interface TZPhotoPreviewController () { UICollectionView *_collectionView; - UICollectionViewFlowLayout *_layout; + TZCollectionViewFlowLayout *_layout; NSArray *_photosTemp; NSArray *_assetsTemp; @@ -106,11 +107,17 @@ - (void)configCustomNaviBar { _naviBar.backgroundColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:0.7]; _backButton = [[UIButton alloc] initWithFrame:CGRectZero]; - [_backButton setImage:[UIImage tz_imageNamedFromMyBundle:@"navi_back"] forState:UIControlStateNormal]; + UIImage *backImage = [UIImage tz_imageNamedFromMyBundle:@"navi_back"]; + if ([TZCommonTools tz_isRightToLeftLayout]) { + backImage = [UIImage imageWithCGImage:backImage.CGImage scale:backImage.scale orientation:UIImageOrientationDown]; + } + _backButton.translatesAutoresizingMaskIntoConstraints = NO; + [_backButton setImage:backImage forState:UIControlStateNormal]; [_backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [_backButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside]; _selectButton = [[UIButton alloc] initWithFrame:CGRectZero]; + _selectButton.translatesAutoresizingMaskIntoConstraints = NO; [_selectButton setImage:tzImagePickerVc.photoDefImage forState:UIControlStateNormal]; [_selectButton setImage:tzImagePickerVc.photoSelImage forState:UIControlStateSelected]; _selectButton.imageView.clipsToBounds = YES; @@ -120,6 +127,7 @@ - (void)configCustomNaviBar { _selectButton.hidden = !tzImagePickerVc.showSelectBtn; _indexLabel = [[UILabel alloc] init]; + _indexLabel.translatesAutoresizingMaskIntoConstraints = NO; _indexLabel.adjustsFontSizeToFitWidth = YES; _indexLabel.font = [UIFont systemFontOfSize:14]; _indexLabel.textColor = [UIColor whiteColor]; @@ -129,6 +137,29 @@ - (void)configCustomNaviBar { [_naviBar addSubview:_indexLabel]; [_naviBar addSubview:_backButton]; [self.view addSubview:_naviBar]; + + NSLayoutConstraint *backButton_left = [NSLayoutConstraint constraintWithItem:_backButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_naviBar attribute:NSLayoutAttributeLeading multiplier:1.0 constant:10]; + NSLayoutConstraint *backButton_bottom = [NSLayoutConstraint constraintWithItem:_backButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:_naviBar attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5]; + NSLayoutConstraint *backButton_width = [NSLayoutConstraint constraintWithItem:_backButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:44]; + NSLayoutConstraint *backButton_height = [NSLayoutConstraint constraintWithItem:_backButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:44]; + [_naviBar addConstraints:@[backButton_left,backButton_bottom]]; + [_backButton addConstraints:@[backButton_width,backButton_height]]; + + NSLayoutConstraint *selectButton_right = [NSLayoutConstraint constraintWithItem:_selectButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:_naviBar attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-12]; + NSLayoutConstraint *selectButton_centerY = [NSLayoutConstraint constraintWithItem:_selectButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_backButton attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + NSLayoutConstraint *selectButton_width = [NSLayoutConstraint constraintWithItem:_selectButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:44]; + NSLayoutConstraint *selectButton_height = [NSLayoutConstraint constraintWithItem:_selectButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:44]; + [_naviBar addConstraints:@[selectButton_right,selectButton_centerY]]; + [_selectButton addConstraints:@[selectButton_width,selectButton_height]]; + + NSLayoutConstraint *indexLabel_centerX = [NSLayoutConstraint constraintWithItem:_indexLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:_selectButton attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]; + NSLayoutConstraint *indexLabel_centerY = [NSLayoutConstraint constraintWithItem:_indexLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_selectButton attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + NSLayoutConstraint *indexLabel_width = [NSLayoutConstraint constraintWithItem:_indexLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:_selectButton attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]; + NSLayoutConstraint *indexLabel_height = [NSLayoutConstraint constraintWithItem:_indexLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:_selectButton attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0]; + [_naviBar addConstraints:@[indexLabel_centerX,indexLabel_centerY,indexLabel_width,indexLabel_height]]; + + + } - (void)configBottomToolBar { @@ -139,6 +170,7 @@ - (void)configBottomToolBar { TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController; if (_tzImagePickerVc.allowPickingOriginalPhoto) { _originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom]; + _originalPhotoButton.translatesAutoresizingMaskIntoConstraints = NO; _originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, [TZCommonTools tz_isRightToLeftLayout] ? 10 : -10, 0, 0); _originalPhotoButton.backgroundColor = [UIColor clearColor]; [_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside]; @@ -151,6 +183,7 @@ - (void)configBottomToolBar { [_originalPhotoButton setImage:_tzImagePickerVc.photoOriginSelImage forState:UIControlStateSelected]; _originalPhotoLabel = [[UILabel alloc] init]; + _originalPhotoLabel.translatesAutoresizingMaskIntoConstraints = NO; _originalPhotoLabel.textAlignment = NSTextAlignmentLeft; _originalPhotoLabel.font = [UIFont systemFontOfSize:13]; _originalPhotoLabel.textColor = [UIColor whiteColor]; @@ -159,18 +192,21 @@ - (void)configBottomToolBar { } _doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; + _doneButton.translatesAutoresizingMaskIntoConstraints = NO; + _doneButton.titleLabel.font = _tzImagePickerVc.doneBtnTitleFont; [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_doneButton setTitle:_tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal]; [_doneButton setTitleColor:_tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal]; _numberImageView = [[UIImageView alloc] initWithImage:_tzImagePickerVc.photoNumberIconImage]; + _numberImageView.translatesAutoresizingMaskIntoConstraints = NO; _numberImageView.backgroundColor = [UIColor clearColor]; _numberImageView.clipsToBounds = YES; _numberImageView.contentMode = UIViewContentModeScaleAspectFit; _numberImageView.hidden = _tzImagePickerVc.selectedModels.count <= 0; _numberLabel = [[UILabel alloc] init]; + _numberLabel.translatesAutoresizingMaskIntoConstraints = NO; _numberLabel.font = [UIFont systemFontOfSize:15]; _numberLabel.adjustsFontSizeToFitWidth = YES; _numberLabel.textColor = [UIColor whiteColor]; @@ -193,10 +229,41 @@ - (void)configBottomToolBar { if (_tzImagePickerVc.photoPreviewPageUIConfigBlock) { _tzImagePickerVc.photoPreviewPageUIConfigBlock(_collectionView, _naviBar, _backButton, _selectButton, _indexLabel, _toolBar, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel); } + + if (_tzImagePickerVc.allowPickingOriginalPhoto) { + CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width; + + NSLayoutConstraint *originalPhotoButton_left = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]; + NSLayoutConstraint *originalPhotoButton_top = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:10]; + NSLayoutConstraint *originalPhotoButton_width = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeWidth multiplier:1.0 constant:fullImageWidth + 56]; + NSLayoutConstraint *originalPhotoButton_height = [NSLayoutConstraint constraintWithItem:_originalPhotoButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:44]; + [_toolBar addConstraints:@[originalPhotoButton_left,originalPhotoButton_top]]; + [_originalPhotoButton addConstraints:@[originalPhotoButton_width,originalPhotoButton_height]]; + + NSLayoutConstraint *originalPhotoLabel_left = [NSLayoutConstraint constraintWithItem:_originalPhotoLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:_originalPhotoButton attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-10]; + NSLayoutConstraint *originalPhotoLabel_centerY = [NSLayoutConstraint constraintWithItem:_originalPhotoLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_originalPhotoButton attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + [_toolBar addConstraints:@[originalPhotoLabel_left,originalPhotoLabel_centerY]]; + } + + NSLayoutConstraint *doneButton_right = [NSLayoutConstraint constraintWithItem:_doneButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-12]; + NSLayoutConstraint *doneButton_top = [NSLayoutConstraint constraintWithItem:_doneButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_toolBar attribute:NSLayoutAttributeTop multiplier:1.0 constant:10]; + [_toolBar addConstraints:@[doneButton_right,doneButton_top]]; + + NSLayoutConstraint *numberImage_right = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:_doneButton attribute:NSLayoutAttributeLeading multiplier:1.0 constant:-5]; + NSLayoutConstraint *numberImage_centerY = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_doneButton attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + NSLayoutConstraint *numberImage_width = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:24]; + NSLayoutConstraint *numberImage_height = [NSLayoutConstraint constraintWithItem:_numberImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:24]; + [_toolBar addConstraints:@[numberImage_right,numberImage_centerY]]; + [_numberImageView addConstraints:@[numberImage_width,numberImage_height]]; + + NSLayoutConstraint *numberLabel_centerX = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:_numberImageView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]; + NSLayoutConstraint *numberLabel_centerY = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_numberImageView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; + [_toolBar addConstraints:@[numberLabel_centerX,numberLabel_centerY]]; + } - (void)configCollectionView { - _layout = [[UICollectionViewFlowLayout alloc] init]; + _layout = [[TZCollectionViewFlowLayout alloc] init]; _layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_layout]; _collectionView.backgroundColor = [UIColor blackColor]; @@ -263,12 +330,8 @@ - (void)viewDidLayoutSubviews { BOOL isFullScreen = self.view.tz_height == [UIScreen mainScreen].bounds.size.height; CGFloat statusBarHeight = isFullScreen ? [TZCommonTools tz_statusBarHeight] : 0; - CGFloat statusBarHeightInterval = isFullScreen ? (statusBarHeight - 20) : 0; 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 - 56, 10 + statusBarHeightInterval, 44, 44); - _indexLabel.frame = _selectButton.frame; _layout.itemSize = CGSizeMake(self.view.tz_width + 20, self.view.tz_height); _layout.minimumInteritemSpacing = 0; @@ -286,15 +349,16 @@ - (void)viewDidLayoutSubviews { CGFloat toolBarHeight = 44 + [TZCommonTools tz_safeAreaInsets].bottom; 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); - _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 42, 0, 80, 44); - } - [_doneButton sizeToFit]; - _doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, MAX(44, _doneButton.tz_width), 44); - _numberImageView.frame = CGRectMake(_doneButton.tz_left - 24 - 5, 10, 24, 24); - _numberLabel.frame = _numberImageView.frame; + +// 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); +// _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 42, 0, 80, 44); +// } +// [_doneButton sizeToFit]; +// _doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, MAX(44, _doneButton.tz_width), 44); +// _numberImageView.frame = CGRectMake(_doneButton.tz_left - 24 - 5, 10, 24, 24); +// _numberLabel.frame = _numberImageView.frame; [self configCropView]; @@ -654,7 +718,8 @@ - (void)showPhotoBytes { } - (NSInteger)currentIndex { - return [TZCommonTools tz_isRightToLeftLayout] ? self.models.count - _currentIndex - 1 : _currentIndex; + return _currentIndex; +// return [TZCommonTools tz_isRightToLeftLayout] ? self.models.count - _currentIndex - 1 : _currentIndex; } /// 选中/取消选中某张照片 diff --git a/TZImagePickerController/TZImagePickerController/TZVideoCropController.m b/TZImagePickerController/TZImagePickerController/TZVideoCropController.m index a631a609..dcc17071 100644 --- a/TZImagePickerController/TZImagePickerController/TZVideoCropController.m +++ b/TZImagePickerController/TZImagePickerController/TZVideoCropController.m @@ -122,7 +122,7 @@ - (void)configBottomToolBar { [self.view addSubview:_cancelButton]; _doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; + _doneButton.titleLabel.font = self.imagePickerVc.doneBtnTitleFont; [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_doneButton setTitle:self.imagePickerVc.doneBtnTitleStr forState:UIControlStateNormal]; [_doneButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; diff --git a/TZImagePickerController/TZImagePickerController/TZVideoEditedPreviewController.m b/TZImagePickerController/TZImagePickerController/TZVideoEditedPreviewController.m index b9755c1e..e8ba445c 100644 --- a/TZImagePickerController/TZImagePickerController/TZVideoEditedPreviewController.m +++ b/TZImagePickerController/TZImagePickerController/TZVideoEditedPreviewController.m @@ -60,15 +60,16 @@ - (void)configBottomToolBar { _toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7]; _doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside]; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; if (tzImagePickerVc) { [_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal]; [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal]; + _doneButton.titleLabel.font = tzImagePickerVc.doneBtnTitleFont; } else { [_doneButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal]; [_doneButton setTitleColor:[UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0] forState:UIControlStateNormal]; + _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; } [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled]; [_toolBar addSubview:_doneButton]; diff --git a/TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m b/TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m index 7175b4df..95dc2cd4 100644 --- a/TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m +++ b/TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m @@ -120,7 +120,6 @@ - (void)configBottomToolBar { _toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7]; _doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; if (!_cover) { _doneButton.enabled = NO; } @@ -129,9 +128,11 @@ - (void)configBottomToolBar { if (tzImagePickerVc) { [_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal]; [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal]; + _doneButton.titleLabel.font = tzImagePickerVc.doneBtnTitleFont; } else { [_doneButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal]; [_doneButton setTitleColor:[UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0] forState:UIControlStateNormal]; + _doneButton.titleLabel.font = [UIFont systemFontOfSize:16]; } [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled]; [_toolBar addSubview:_doneButton];