Commit 55f0f42c authored by banchichen's avatar banchichen

允许更改按钮的文字

parent 3d2d8760
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
@property (nonatomic, assign) BOOL allowCrop; ///< 允许裁剪,默认为YES,showSelectBtn为NO才生效 @property (nonatomic, assign) BOOL allowCrop; ///< 允许裁剪,默认为YES,showSelectBtn为NO才生效
@property (nonatomic, assign) CGRect cropRect; ///< 裁剪框的尺寸 @property (nonatomic, assign) CGRect cropRect; ///< 裁剪框的尺寸
@property (nonatomic, copy) void (^cropViewSettingBlock)(UIView *cropView); ///< 自定义裁剪框的其他属性 @property (nonatomic, copy) void (^cropViewSettingBlock)(UIView *cropView); ///< 自定义裁剪框的其他属性
@property (nonatomic, copy) void (^cropBgViewSettingBlock)(UIView *cropBgView); ///< 自定义裁剪框背景的其他属性
- (void)showAlertWithTitle:(NSString *)title; - (void)showAlertWithTitle:(NSString *)title;
- (void)showProgressHUD; - (void)showProgressHUD;
...@@ -112,12 +113,19 @@ ...@@ -112,12 +113,19 @@
@property (nonatomic, copy) NSString *photoPreviewOriginDefImageName; @property (nonatomic, copy) NSString *photoPreviewOriginDefImageName;
@property (nonatomic, copy) NSString *photoNumberIconImageName; @property (nonatomic, copy) NSString *photoNumberIconImageName;
/// Appearance / 外观颜色 /// Appearance / 外观颜色 + 按钮文字
@property (nonatomic, strong) UIColor *oKButtonTitleColorNormal; @property (nonatomic, strong) UIColor *oKButtonTitleColorNormal;
@property (nonatomic, strong) UIColor *oKButtonTitleColorDisabled; @property (nonatomic, strong) UIColor *oKButtonTitleColorDisabled;
@property (nonatomic, strong) UIColor *barItemTextColor; @property (nonatomic, strong) UIColor *barItemTextColor;
@property (nonatomic, strong) UIFont *barItemTextFont; @property (nonatomic, strong) UIFont *barItemTextFont;
@property (nonatomic, copy) NSString *doneBtnTitleStr;
@property (nonatomic, copy) NSString *cancelBtnTitleStr;
@property (nonatomic, copy) NSString *previewBtnTitleStr;
@property (nonatomic, copy) NSString *fullImageBtnTitleStr;
@property (nonatomic, copy) NSString *settingBtnTitleStr;
@property (nonatomic, copy) NSString *processHintStr;
// The picker should dismiss itself; when it dismissed these handle will be called. // The picker should dismiss itself; when it dismissed these handle will be called.
// You can also set autoDismiss to NO, then the picker don't dismiss itself. // You can also set autoDismiss to NO, then the picker don't dismiss itself.
// If isOriginalPhoto is YES, user picked the original photo. // If isOriginalPhoto is YES, user picked the original photo.
......
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
self.barItemTextColor = [UIColor whiteColor]; self.barItemTextColor = [UIColor whiteColor];
self.columnNumber = columnNumber; self.columnNumber = columnNumber;
[self configDefaultImageName]; [self configDefaultImageName];
[self configDefaultBtnTitle];
if (![[TZImageManager manager] authorizationStatusAuthorized]) { if (![[TZImageManager manager] authorizationStatusAuthorized]) {
_tipLable = [[UILabel alloc] init]; _tipLable = [[UILabel alloc] init];
...@@ -143,7 +144,7 @@ ...@@ -143,7 +144,7 @@
[self.view addSubview:_tipLable]; [self.view addSubview:_tipLable];
_settingBtn = [UIButton buttonWithType:UIButtonTypeSystem]; _settingBtn = [UIButton buttonWithType:UIButtonTypeSystem];
[_settingBtn setTitle:[NSBundle tz_localizedStringForKey:@"Setting"] forState:UIControlStateNormal]; [_settingBtn setTitle:self.settingBtnTitleStr forState:UIControlStateNormal];
_settingBtn.frame = CGRectMake(0, 180, self.view.tz_width, 44); _settingBtn.frame = CGRectMake(0, 180, self.view.tz_width, 44);
_settingBtn.titleLabel.font = [UIFont systemFontOfSize:18]; _settingBtn.titleLabel.font = [UIFont systemFontOfSize:18];
[_settingBtn addTarget:self action:@selector(settingBtnClick) forControlEvents:UIControlEventTouchUpInside]; [_settingBtn addTarget:self action:@selector(settingBtnClick) forControlEvents:UIControlEventTouchUpInside];
...@@ -170,6 +171,7 @@ ...@@ -170,6 +171,7 @@
self.barItemTextFont = [UIFont systemFontOfSize:15]; self.barItemTextFont = [UIFont systemFontOfSize:15];
self.barItemTextColor = [UIColor whiteColor]; self.barItemTextColor = [UIColor whiteColor];
[self configDefaultImageName]; [self configDefaultImageName];
[self configDefaultBtnTitle];
previewVc.photos = [NSMutableArray arrayWithArray:selectedPhotos]; previewVc.photos = [NSMutableArray arrayWithArray:selectedPhotos];
previewVc.currentIndex = index; previewVc.currentIndex = index;
...@@ -194,6 +196,15 @@ ...@@ -194,6 +196,15 @@
self.photoOriginSelImageName = @"photo_original_sel.png"; self.photoOriginSelImageName = @"photo_original_sel.png";
} }
- (void)configDefaultBtnTitle {
self.doneBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Done"];
self.cancelBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Cancel"];
self.previewBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Preview"];
self.fullImageBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Full image"];
self.settingBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Setting"];
self.processHintStr = [NSBundle tz_localizedStringForKey:@"Processing..."];
}
- (void)observeAuthrizationStatusChange { - (void)observeAuthrizationStatusChange {
if ([[TZImageManager manager] authorizationStatusAuthorized]) { if ([[TZImageManager manager] authorizationStatusAuthorized]) {
[_tipLable removeFromSuperview]; [_tipLable removeFromSuperview];
...@@ -250,7 +261,7 @@ ...@@ -250,7 +261,7 @@
_HUDLable = [[UILabel alloc] init]; _HUDLable = [[UILabel alloc] init];
_HUDLable.frame = CGRectMake(0,40, 120, 50); _HUDLable.frame = CGRectMake(0,40, 120, 50);
_HUDLable.textAlignment = NSTextAlignmentCenter; _HUDLable.textAlignment = NSTextAlignmentCenter;
_HUDLable.text = @"正在处理..."; _HUDLable.text = self.processHintStr;
_HUDLable.font = [UIFont systemFontOfSize:15]; _HUDLable.font = [UIFont systemFontOfSize:15];
_HUDLable.textColor = [UIColor whiteColor]; _HUDLable.textColor = [UIColor whiteColor];
...@@ -421,7 +432,8 @@ ...@@ -421,7 +432,8 @@
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.title = [NSBundle tz_localizedStringForKey:@"Photos"]; self.navigationItem.title = [NSBundle tz_localizedStringForKey:@"Photos"];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Cancel"] style:UIBarButtonItemStylePlain target:self action:@selector(cancel)]; TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:imagePickerVc.cancelBtnTitleStr style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
[self configTableView]; [self configTableView];
// 1.6.10 采用微信的方式,只在相册列表页定义backBarButtonItem为返回,其余的顺系统的做法 // 1.6.10 采用微信的方式,只在相册列表页定义backBarButtonItem为返回,其余的顺系统的做法
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Back"] style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Back"] style:UIBarButtonItemStylePlain target:nil action:nil];
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
NSMutableArray *_models; NSMutableArray *_models;
UIButton *_previewButton; UIButton *_previewButton;
UIButton *_okButton; UIButton *_doneButton;
UIImageView *_numberImageView; UIImageView *_numberImageView;
UILabel *_numberLable; UILabel *_numberLable;
UIButton *_originalPhotoButton; UIButton *_originalPhotoButton;
...@@ -69,7 +69,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -69,7 +69,7 @@ static CGSize AssetGridThumbnailSize;
_shouldScrollToBottom = YES; _shouldScrollToBottom = YES;
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.title = _model.name; self.navigationItem.title = _model.name;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Cancel"] style:UIBarButtonItemStylePlain target:self action:@selector(cancel)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:tzImagePickerVc.cancelBtnTitleStr style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
_showTakePhotoBtn = (([[TZImageManager manager] isCameraRollAlbum:_model.name]) && tzImagePickerVc.allowTakePicture); _showTakePhotoBtn = (([[TZImageManager manager] isCameraRollAlbum:_model.name]) && tzImagePickerVc.allowTakePicture);
if (!tzImagePickerVc.sortAscendingByModificationDate && _isFirstAppear && iOS8Later) { if (!tzImagePickerVc.sortAscendingByModificationDate && _isFirstAppear && iOS8Later) {
[[TZImageManager manager] getCameraRollAlbum:tzImagePickerVc.allowPickingVideo allowPickingImage:tzImagePickerVc.allowPickingImage completion:^(TZAlbumModel *model) { [[TZImageManager manager] getCameraRollAlbum:tzImagePickerVc.allowPickingVideo allowPickingImage:tzImagePickerVc.allowPickingImage completion:^(TZAlbumModel *model) {
...@@ -166,29 +166,27 @@ static CGSize AssetGridThumbnailSize; ...@@ -166,29 +166,27 @@ static CGSize AssetGridThumbnailSize;
CGFloat rgb = 253 / 255.0; CGFloat rgb = 253 / 255.0;
bottomToolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0]; bottomToolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
NSString *previewText = [NSBundle tz_localizedStringForKey:@"Preview"]; CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.width;
CGFloat previewWidth = [previewText boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.width;
_previewButton = [UIButton buttonWithType:UIButtonTypeCustom]; _previewButton = [UIButton buttonWithType:UIButtonTypeCustom];
_previewButton.frame = CGRectMake(10, 3, previewWidth + 2, 44); _previewButton.frame = CGRectMake(10, 3, previewWidth + 2, 44);
_previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth + 2; _previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth + 2;
[_previewButton addTarget:self action:@selector(previewButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_previewButton addTarget:self action:@selector(previewButtonClick) forControlEvents:UIControlEventTouchUpInside];
_previewButton.titleLabel.font = [UIFont systemFontOfSize:16]; _previewButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_previewButton setTitle:previewText forState:UIControlStateNormal]; [_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateNormal];
[_previewButton setTitle:previewText forState:UIControlStateDisabled]; [_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateDisabled];
[_previewButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [_previewButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[_previewButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled]; [_previewButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
_previewButton.enabled = tzImagePickerVc.selectedModels.count; _previewButton.enabled = tzImagePickerVc.selectedModels.count;
if (tzImagePickerVc.allowPickingOriginalPhoto) { if (tzImagePickerVc.allowPickingOriginalPhoto) {
NSString *fullImageText = [NSBundle tz_localizedStringForKey:@"Full image"]; CGFloat fullImageWidth = [tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
CGFloat fullImageWidth = [fullImageText boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
_originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom]; _originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_originalPhotoButton.frame = CGRectMake(CGRectGetMaxX(_previewButton.frame), self.view.tz_height - 50, fullImageWidth + 56, 50); _originalPhotoButton.frame = CGRectMake(CGRectGetMaxX(_previewButton.frame), self.view.tz_height - 50, fullImageWidth + 56, 50);
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0); _originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
[_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside];
_originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:16]; _originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_originalPhotoButton setTitle:fullImageText forState:UIControlStateNormal]; [_originalPhotoButton setTitle:tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateNormal];
[_originalPhotoButton setTitle:fullImageText forState:UIControlStateSelected]; [_originalPhotoButton setTitle:tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateSelected];
[_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[_originalPhotoButton setTitleColor:[UIColor blackColor] forState:UIControlStateSelected]; [_originalPhotoButton setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
[_originalPhotoButton setImage:[UIImage imageNamedFromMyBundle:tzImagePickerVc.photoOriginDefImageName] forState:UIControlStateNormal]; [_originalPhotoButton setImage:[UIImage imageNamedFromMyBundle:tzImagePickerVc.photoOriginDefImageName] forState:UIControlStateNormal];
...@@ -204,15 +202,15 @@ static CGSize AssetGridThumbnailSize; ...@@ -204,15 +202,15 @@ static CGSize AssetGridThumbnailSize;
if (_isSelectOriginalPhoto) [self getSelectedPhotoBytes]; if (_isSelectOriginalPhoto) [self getSelectedPhotoBytes];
} }
_okButton = [UIButton buttonWithType:UIButtonTypeCustom]; _doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_okButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 3, 44, 44); _doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 3, 44, 44);
_okButton.titleLabel.font = [UIFont systemFontOfSize:16]; _doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_okButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal]; [_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
[_okButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateDisabled]; [_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateDisabled];
[_okButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal]; [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
[_okButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled]; [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled];
_okButton.enabled = tzImagePickerVc.selectedModels.count || tzImagePickerVc.alwaysEnableDoneBtn; _doneButton.enabled = tzImagePickerVc.selectedModels.count || tzImagePickerVc.alwaysEnableDoneBtn;
_numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamedFromMyBundle:tzImagePickerVc.photoNumberIconImageName]]; _numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamedFromMyBundle:tzImagePickerVc.photoNumberIconImageName]];
_numberImageView.frame = CGRectMake(self.view.tz_width - 56 - 28, 10, 30, 30); _numberImageView.frame = CGRectMake(self.view.tz_width - 56 - 28, 10, 30, 30);
...@@ -235,7 +233,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -235,7 +233,7 @@ static CGSize AssetGridThumbnailSize;
[bottomToolBar addSubview:divide]; [bottomToolBar addSubview:divide];
[bottomToolBar addSubview:_previewButton]; [bottomToolBar addSubview:_previewButton];
[bottomToolBar addSubview:_okButton]; [bottomToolBar addSubview:_doneButton];
[bottomToolBar addSubview:_numberImageView]; [bottomToolBar addSubview:_numberImageView];
[bottomToolBar addSubview:_numberLable]; [bottomToolBar addSubview:_numberLable];
[self.view addSubview:bottomToolBar]; [self.view addSubview:bottomToolBar];
...@@ -273,7 +271,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -273,7 +271,7 @@ static CGSize AssetGridThumbnailSize;
if (_isSelectOriginalPhoto) [self getSelectedPhotoBytes]; if (_isSelectOriginalPhoto) [self getSelectedPhotoBytes];
} }
- (void)okButtonClick { - (void)doneButtonClick {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
// 1.6.8 判断是否满足最小必选张数的限制 // 1.6.8 判断是否满足最小必选张数的限制
if (tzImagePickerVc.minImagesCount && tzImagePickerVc.selectedModels.count < tzImagePickerVc.minImagesCount) { if (tzImagePickerVc.minImagesCount && tzImagePickerVc.selectedModels.count < tzImagePickerVc.minImagesCount) {
...@@ -450,12 +448,14 @@ static CGSize AssetGridThumbnailSize; ...@@ -450,12 +448,14 @@ static CGSize AssetGridThumbnailSize;
[alert show]; [alert show];
#pragma clang diagnostic pop #pragma clang diagnostic pop
} else { // 调用相机 } else { // 调用相机
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
self.imagePickerVc.sourceType = sourceType; self.imagePickerVc.sourceType = sourceType;
if(iOS8Later) { if(iOS8Later) {
_imagePickerVc.modalPresentationStyle = UIModalPresentationOverCurrentContext; _imagePickerVc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
} }
self.imagePickerVc.allowsEditing = tzImagePickerVc.allowCrop;
[self presentViewController:_imagePickerVc animated:YES completion:nil]; [self presentViewController:_imagePickerVc animated:YES completion:nil];
} else { } else {
NSLog(@"模拟器中无法打开照相机,请在真机中使用"); NSLog(@"模拟器中无法打开照相机,请在真机中使用");
...@@ -467,7 +467,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -467,7 +467,7 @@ static CGSize AssetGridThumbnailSize;
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_previewButton.enabled = tzImagePickerVc.selectedModels.count > 0; _previewButton.enabled = tzImagePickerVc.selectedModels.count > 0;
_okButton.enabled = tzImagePickerVc.selectedModels.count > 0 || tzImagePickerVc.alwaysEnableDoneBtn; _doneButton.enabled = tzImagePickerVc.selectedModels.count > 0 || tzImagePickerVc.alwaysEnableDoneBtn;
_numberImageView.hidden = tzImagePickerVc.selectedModels.count <= 0; _numberImageView.hidden = tzImagePickerVc.selectedModels.count <= 0;
_numberLable.hidden = tzImagePickerVc.selectedModels.count <= 0; _numberLable.hidden = tzImagePickerVc.selectedModels.count <= 0;
...@@ -489,7 +489,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -489,7 +489,7 @@ static CGSize AssetGridThumbnailSize;
}]; }];
[photoPreviewVc setDoneButtonClickBlock:^(BOOL isSelectOriginalPhoto) { [photoPreviewVc setDoneButtonClickBlock:^(BOOL isSelectOriginalPhoto) {
weakSelf.isSelectOriginalPhoto = isSelectOriginalPhoto; weakSelf.isSelectOriginalPhoto = isSelectOriginalPhoto;
[weakSelf okButtonClick]; [weakSelf doneButtonClick];
}]; }];
[photoPreviewVc setDoneButtonClickBlockCropMode:^(UIImage *cropedImage, id asset) { [photoPreviewVc setDoneButtonClickBlockCropMode:^(UIImage *cropedImage, id asset) {
[weakSelf didGetAllPhotos:@[cropedImage] assets:@[asset] infoArr:nil]; [weakSelf didGetAllPhotos:@[cropedImage] assets:@[asset] infoArr:nil];
...@@ -575,7 +575,12 @@ static CGSize AssetGridThumbnailSize; ...@@ -575,7 +575,12 @@ static CGSize AssetGridThumbnailSize;
if ([type isEqualToString:@"public.image"]) { if ([type isEqualToString:@"public.image"]) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showProgressHUD]; [imagePickerVc showProgressHUD];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; UIImage *image;
if (imagePickerVc.allowCrop) {
image = [info objectForKey:UIImagePickerControllerEditedImage];
} else {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
}
[[TZImageManager manager] savePhotoWithImage:image completion:^(NSError *error){ [[TZImageManager manager] savePhotoWithImage:image completion:^(NSError *error){
if (!error) { if (!error) {
[self reloadPhotoArray]; [self reloadPhotoArray];
...@@ -602,7 +607,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -602,7 +607,7 @@ static CGSize AssetGridThumbnailSize;
if (tzImagePickerVc.maxImagesCount <= 1) { if (tzImagePickerVc.maxImagesCount <= 1) {
[tzImagePickerVc.selectedModels addObject:assetModel]; [tzImagePickerVc.selectedModels addObject:assetModel];
[self okButtonClick]; return; [self doneButtonClick]; return;
} }
if (tzImagePickerVc.selectedModels.count < tzImagePickerVc.maxImagesCount) { if (tzImagePickerVc.selectedModels.count < tzImagePickerVc.maxImagesCount) {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
UIButton *_selectButton; UIButton *_selectButton;
UIView *_toolBar; UIView *_toolBar;
UIButton *_okButton; UIButton *_doneButton;
UIImageView *_numberImageView; UIImageView *_numberImageView;
UILabel *_numberLable; UILabel *_numberLable;
UIButton *_originalPhotoButton; UIButton *_originalPhotoButton;
...@@ -107,16 +107,15 @@ ...@@ -107,16 +107,15 @@
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_tzImagePickerVc.allowPickingOriginalPhoto) { if (_tzImagePickerVc.allowPickingOriginalPhoto) {
NSString *fullImageText = [NSBundle tz_localizedStringForKey:@"Full image"]; CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
CGFloat fullImageWidth = [fullImageText boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width;
_originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom]; _originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44); _originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44);
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0); _originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
_originalPhotoButton.backgroundColor = [UIColor clearColor]; _originalPhotoButton.backgroundColor = [UIColor clearColor];
[_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside];
_originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:13]; _originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_originalPhotoButton setTitle:fullImageText forState:UIControlStateNormal]; [_originalPhotoButton setTitle:_tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateNormal];
[_originalPhotoButton setTitle:fullImageText forState:UIControlStateSelected]; [_originalPhotoButton setTitle:_tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateSelected];
[_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[_originalPhotoButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected]; [_originalPhotoButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
[_originalPhotoButton setImage:[UIImage imageNamedFromMyBundle:_tzImagePickerVc.photoPreviewOriginDefImageName] forState:UIControlStateNormal]; [_originalPhotoButton setImage:[UIImage imageNamedFromMyBundle:_tzImagePickerVc.photoPreviewOriginDefImageName] forState:UIControlStateNormal];
...@@ -131,12 +130,12 @@ ...@@ -131,12 +130,12 @@
if (_isSelectOriginalPhoto) [self showPhotoBytes]; if (_isSelectOriginalPhoto) [self showPhotoBytes];
} }
_okButton = [UIButton buttonWithType:UIButtonTypeCustom]; _doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_okButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44); _doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_okButton.titleLabel.font = [UIFont systemFontOfSize:16]; _doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_okButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_okButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal]; [_doneButton setTitle:_tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
[_okButton setTitleColor:_tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal]; [_doneButton setTitleColor:_tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
_numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamedFromMyBundle:_tzImagePickerVc.photoNumberIconImageName]]; _numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamedFromMyBundle:_tzImagePickerVc.photoNumberIconImageName]];
_numberImageView.backgroundColor = [UIColor clearColor]; _numberImageView.backgroundColor = [UIColor clearColor];
...@@ -153,7 +152,7 @@ ...@@ -153,7 +152,7 @@
_numberLable.backgroundColor = [UIColor clearColor]; _numberLable.backgroundColor = [UIColor clearColor];
[_originalPhotoButton addSubview:_originalPhotoLable]; [_originalPhotoButton addSubview:_originalPhotoLable];
[_toolBar addSubview:_okButton]; [_toolBar addSubview:_doneButton];
[_toolBar addSubview:_originalPhotoButton]; [_toolBar addSubview:_originalPhotoButton];
[_toolBar addSubview:_numberImageView]; [_toolBar addSubview:_numberImageView];
[_toolBar addSubview:_numberLable]; [_toolBar addSubview:_numberLable];
...@@ -189,6 +188,9 @@ ...@@ -189,6 +188,9 @@
_cropBgView.alpha = 0.5; _cropBgView.alpha = 0.5;
_cropBgView.frame = self.view.bounds; _cropBgView.frame = self.view.bounds;
[self.view addSubview:_cropBgView]; [self.view addSubview:_cropBgView];
if (_tzImagePickerVc.cropBgViewSettingBlock) {
_tzImagePickerVc.cropBgViewSettingBlock(_cropBgView);
}
[TZImageCropManager overlayClippingWithView:_cropBgView cropRect:_tzImagePickerVc.cropRect containerView:self.view]; [TZImageCropManager overlayClippingWithView:_cropBgView cropRect:_tzImagePickerVc.cropRect containerView:self.view];
_cropView = [UIView new]; _cropView = [UIView new];
...@@ -397,7 +399,7 @@ ...@@ -397,7 +399,7 @@
} }
} }
_okButton.hidden = NO; _doneButton.hidden = NO;
_selectButton.hidden = !_tzImagePickerVc.showSelectBtn; _selectButton.hidden = !_tzImagePickerVc.showSelectBtn;
// 让宽度/高度小于 最小可选照片尺寸 的图片不能选中 // 让宽度/高度小于 最小可选照片尺寸 的图片不能选中
if (![[TZImageManager manager] isPhotoSelectableWithAsset:model.asset]) { if (![[TZImageManager manager] isPhotoSelectableWithAsset:model.asset]) {
...@@ -406,7 +408,7 @@ ...@@ -406,7 +408,7 @@
_selectButton.hidden = YES; _selectButton.hidden = YES;
_originalPhotoButton.hidden = YES; _originalPhotoButton.hidden = YES;
_originalPhotoLable.hidden = YES; _originalPhotoLable.hidden = YES;
_okButton.hidden = YES; _doneButton.hidden = YES;
} }
} }
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor]; self.view.backgroundColor = [UIColor blackColor];
self.navigationItem.title = [NSBundle tz_localizedStringForKey:@"Preview"]; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
self.navigationItem.title = tzImagePickerVc.previewBtnTitleStr;
[self configMoviePlayer]; [self configMoviePlayer];
} }
...@@ -84,7 +85,8 @@ ...@@ -84,7 +85,8 @@
_okButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44); _okButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_okButton.titleLabel.font = [UIFont systemFontOfSize:16]; _okButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_okButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal]; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
[_okButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[_okButton setTitleColor:imagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal]; [_okButton setTitleColor:imagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
......
...@@ -69,7 +69,6 @@ ...@@ -69,7 +69,6 @@
_selectedPhotos = [NSMutableArray array]; _selectedPhotos = [NSMutableArray array];
_selectedAssets = [NSMutableArray array]; _selectedAssets = [NSMutableArray array];
[self configCollectionView]; [self configCollectionView];
self.maxCountTF.text = @"1";
} }
- (BOOL)prefersStatusBarHidden { - (BOOL)prefersStatusBarHidden {
...@@ -237,6 +236,10 @@ ...@@ -237,6 +236,10 @@
cropView.layer.borderColor = [UIColor redColor].CGColor; cropView.layer.borderColor = [UIColor redColor].CGColor;
cropView.layer.borderWidth = 2.0; cropView.layer.borderWidth = 2.0;
}]; }];
/*
[imagePickerVc setCropBgViewSettingBlock:^(UIView *cropBgView) {
cropBgView.alpha = 0.5;
}];*/
#pragma mark - 到这里为止 #pragma mark - 到这里为止
// You can get the photos by block, the same as by delegate. // You can get the photos by block, the same as by delegate.
......
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