diff --git a/PhotoBrowser/ZLCollectionCell.h b/PhotoBrowser/ZLCollectionCell.h index 5ca35b1c..2ae9e41c 100644 --- a/PhotoBrowser/ZLCollectionCell.h +++ b/PhotoBrowser/ZLCollectionCell.h @@ -18,18 +18,18 @@ @property (nonatomic, strong) UIImageView *videoImageView; @property (nonatomic, strong) UIImageView *liveImageView; @property (nonatomic, strong) UILabel *timeLabel; -//@property (nonatomic, strong) UIView *topView; +@property (nonatomic, strong) UIView *topView; @property (nonatomic, assign) BOOL allSelectGif; @property (nonatomic, assign) BOOL allSelectLivePhoto; @property (nonatomic, assign) BOOL showSelectBtn; @property (nonatomic, assign) CGFloat cornerRadio; @property (nonatomic, strong) ZLPhotoModel *model; +@property (nonatomic, strong) UIColor *maskColor; +@property (nonatomic, assign) BOOL showMask; @property (nonatomic, copy) void (^selectedBlock)(BOOL); -@property (nonatomic, copy) BOOL (^isSelectedImage)(); - @end diff --git a/PhotoBrowser/ZLCollectionCell.m b/PhotoBrowser/ZLCollectionCell.m index 122f4442..97d81717 100644 --- a/PhotoBrowser/ZLCollectionCell.m +++ b/PhotoBrowser/ZLCollectionCell.m @@ -32,7 +32,9 @@ - (void)layoutSubviews [super layoutSubviews]; self.imageView.frame = self.bounds; self.btnSelect.frame = CGRectMake(GetViewWidth(self.contentView)-26, 5, 23, 23); - // self.topView.frame = self.bounds; + if (self.showMask) { + self.topView.frame = self.bounds; + } self.videoBottomView.frame = CGRectMake(0, GetViewHeight(self)-15, GetViewWidth(self), 15); self.videoImageView.frame = CGRectMake(5, 1, 16, 12); self.liveImageView.frame = CGRectMake(5, -1, 15, 15); @@ -49,6 +51,7 @@ - (UIImageView *)imageView _imageView.clipsToBounds = YES; [self.contentView addSubview:_imageView]; + [self.contentView bringSubviewToFront:_topView]; [self.contentView bringSubviewToFront:self.videoBottomView]; [self.contentView bringSubviewToFront:self.btnSelect]; } @@ -112,19 +115,16 @@ - (UILabel *)timeLabel return _timeLabel; } -//- (UIView *)topView -//{ -// if (!_topView) { -// _topView = [[UIView alloc] init]; -// _topView.backgroundColor = [UIColor whiteColor]; -// _topView.alpha = 0.5; -// _topView.userInteractionEnabled = NO; -// _topView.hidden = YES; -// [self.contentView addSubview:_topView]; -// [self.contentView bringSubviewToFront:_topView]; -// } -// return _topView; -//} +- (UIView *)topView +{ + if (!_topView) { + _topView = [[UIView alloc] init]; + _topView.userInteractionEnabled = NO; + _topView.hidden = YES; + [self.contentView addSubview:_topView]; + } + return _topView; +} - (void)setModel:(ZLPhotoModel *)model { @@ -140,28 +140,23 @@ - (void)setModel:(ZLPhotoModel *)model self.videoImageView.hidden = NO; self.liveImageView.hidden = YES; self.timeLabel.text = model.duration; -// if (self.isSelectedImage) { -// self.topView.hidden = !self.isSelectedImage(); -// } } else if (model.type == ZLAssetMediaTypeGif) { self.videoBottomView.hidden = !self.allSelectGif; self.videoImageView.hidden = YES; self.liveImageView.hidden = YES; self.timeLabel.text = @"GIF"; -// if (self.allSelectGif && self.isSelectedImage) { -// self.topView.hidden = self.allSelectGif && !self.isSelectedImage(); -// } } else if (model.type == ZLAssetMediaTypeLivePhoto) { self.videoBottomView.hidden = !self.allSelectLivePhoto; self.videoImageView.hidden = YES; self.liveImageView.hidden = NO; self.timeLabel.text = @"Live"; -// if (self.allSelectLivePhoto && self.isSelectedImage) { -// self.topView.hidden = self.allSelectLivePhoto && !self.isSelectedImage(); -// } } else { self.videoBottomView.hidden = YES; -// self.topView.hidden = YES; + } + + if (self.showMask) { + self.topView.backgroundColor = [self.maskColor colorWithAlphaComponent:.2]; + self.topView.hidden = !model.isSelected; } self.btnSelect.hidden = !self.showSelectBtn; diff --git a/PhotoBrowser/ZLDefine.h b/PhotoBrowser/ZLDefine.h index 3a799af7..370bf9fd 100644 --- a/PhotoBrowser/ZLDefine.h +++ b/PhotoBrowser/ZLDefine.h @@ -159,7 +159,7 @@ static inline NSInteger GetDuration (NSString *duration) { static inline NSDictionary * -GetCustomRatio() { +GetCustomClipRatio() { return @{ClippingRatioValue1: @(0), ClippingRatioValue2: @(0), ClippingRatioTitleFormat: @"Custom"}; } diff --git a/PhotoBrowser/ZLPhotoActionSheet.h b/PhotoBrowser/ZLPhotoActionSheet.h index 7337217e..be8474cf 100644 --- a/PhotoBrowser/ZLPhotoActionSheet.h +++ b/PhotoBrowser/ZLPhotoActionSheet.h @@ -79,17 +79,17 @@ NS_ASSUME_NONNULL_BEGIN /**导航条颜色,默认 rgb(19, 153, 231)*/ @property (nonatomic, strong) UIColor *navBarColor; -/**选择照片回调,回调解析好的图片、对应的asset对象、是否原图*/ -@property (nonatomic, copy) void (^selectImageBlock)(NSArray *images, NSArray *assets, BOOL isOriginal); - -/**选择gif照片回调,回调解析好的gif图片、对应的asset对象*/ -@property (nonatomic, copy) void (^selectGifBlock)(UIImage *gif, PHAsset *asset) NS_DEPRECATED_IOS(2_0, 8_0, "pod 2.2.6版本之后已废弃,删除使用的地方即可, 统一通过selectImageBlock回调,后续将删除"); +/**是否在已选择的图片上方覆盖一层已选中遮罩层,默认 NO*/ +@property (nonatomic, assign) BOOL showSelectedMask; -/**选择live photo照片回调,回调解析好的live photo图片、对应的asset对象*/ -@property (nonatomic, copy) void (^selectLivePhotoBlock)(UIImage *livePhoto, PHAsset *asset) NS_DEPRECATED_IOS(2_0, 8_0, "pod 2.2.6版本之后已废弃,删除使用的地方即可, 统一通过selectImageBlock回调,后续将删除"); +/**遮罩层颜色,内部会默认调整颜色的透明度为0.2, 默认 blackColor*/ +@property (nonatomic, strong) UIColor *selectedMaskColor; -/**选择视频回调,回调第一帧封面图片、对应的asset对象*/ -@property (nonatomic, copy) void (^selectVideoBlock)(UIImage *cover, PHAsset *asset) NS_DEPRECATED_IOS(2_0, 8_0, "pod 2.2.6版本之后已废弃,删除使用的地方即可, 统一通过selectImageBlock回调,后续将删除"); +/** + 选择照片回调,回调解析好的图片、对应的asset对象、是否原图 + pod 2.2.6版本之后 统一通过selectImageBlock回调 + */ +@property (nonatomic, copy) void (^selectImageBlock)(NSArray *images, NSArray *assets, BOOL isOriginal); - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE; diff --git a/PhotoBrowser/ZLPhotoActionSheet.m b/PhotoBrowser/ZLPhotoActionSheet.m index bc479d88..7db9d3c1 100644 --- a/PhotoBrowser/ZLPhotoActionSheet.m +++ b/PhotoBrowser/ZLPhotoActionSheet.m @@ -16,9 +16,6 @@ #import "ZLThumbnailViewController.h" #import "ZLNoAuthorityViewController.h" #import "ToastUtils.h" -#import "ZLShowGifViewController.h" -#import "ZLShowVideoViewController.h" -#import "ZLShowLivePhotoViewController.h" #import "ZLEditViewController.h" #define kBaseViewHeight (self.maxPreviewCount ? 300 : 142) @@ -93,10 +90,6 @@ - (void)setArrSelectedAssets:(NSMutableArray *)arrSelectedAssets _arrSelectedAssets = arrSelectedAssets; [self.arrSelectedModels removeAllObjects]; for (PHAsset *asset in arrSelectedAssets) { -// if (asset.mediaType != PHAssetMediaTypeImage) { -// //选择的视频不做保存 -// continue; -// } ZLPhotoModel *model = [ZLPhotoModel modelWithAsset:asset type:[ZLPhotoManager transformAssetType:asset] duration:nil]; model.isSelected = YES; [self.arrSelectedModels addObject:model]; @@ -140,6 +133,8 @@ - (instancetype)init self.showCaptureImageOnTakePhotoBtn = YES; self.sortAscending = YES; self.showSelectBtn = NO; + self.showSelectedMask = NO; + self.selectedMaskColor = [UIColor blackColor]; if (![self judgeIsHavePhotoAblumAuthority]) { //注册实施监听相册变化 @@ -300,8 +295,7 @@ - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message - (void)loadPhotoFromAlbum { [self.arrDataSources removeAllObjects]; - //因为预览界面需快速选择最近图片,所以不受self.sortAscending限制, - //这里allow gif和allow liveohoto 置为yes,为了获取所有asset + [self.arrDataSources addObjectsFromArray:[ZLPhotoManager getAllAssetInPhotoAlbumWithAscending:NO limitCount:self.maxPreviewCount allowSelectVideo:self.allowSelectVideo allowSelectImage:self.allowSelectImage allowSelectGif:self.allowSelectGif allowSelectLivePhoto:self.allowSelectLivePhoto]]; [ZLPhotoManager markSelcectModelInArr:self.arrDataSources selArr:self.arrSelectedModels]; [self.collectionView reloadData]; @@ -534,18 +528,19 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell } } } + + if (strongSelf.showSelectedMask) { + strongCell.topView.hidden = !model.isSelected; + } [strongSelf changeCancelBtnTitle]; -// [collectionView reloadItemsAtIndexPaths:[collectionView indexPathsForVisibleItems]]; }; - cell.isSelectedImage = ^BOOL() { - strongify(weakSelf); - return strongSelf.arrSelectedModels.count > 0; - }; cell.allSelectGif = self.allowSelectGif; cell.allSelectLivePhoto = self.allowSelectLivePhoto; cell.showSelectBtn = self.showSelectBtn; cell.cornerRadio = self.cellCornerRadio; + cell.showMask = self.showSelectedMask; + cell.maskColor = self.selectedMaskColor; cell.model = model; return cell; @@ -659,6 +654,8 @@ - (ZLImageNavigationController *)getImageNavWithRootVC:(UIViewController *)rootV nav.showSelectBtn = self.showSelectBtn; nav.isSelectOriginalPhoto = self.isSelectOriginalPhoto; nav.navBarColor = self.navBarColor; + nav.showSelectedMask = self.showSelectedMask; + nav.selectedMaskColor = self.selectedMaskColor; [nav.arrSelectedModels removeAllObjects]; [nav.arrSelectedModels addObjectsFromArray:self.arrSelectedModels]; @@ -708,30 +705,6 @@ - (void)pushEditVCWithModel:(ZLPhotoModel *)model [self.sender showDetailViewController:nav sender:nil]; } -- (void)pushGifViewControllerWithModel:(ZLPhotoModel *)model -{ - ZLShowGifViewController *vc = [[ZLShowGifViewController alloc] init]; - vc.model = model; - ZLImageNavigationController *nav = [self getImageNavWithRootVC:vc]; - [self.sender showDetailViewController:nav sender:nil]; -} - -- (void)pushLivePhotoViewControllerWithModel:(ZLPhotoModel *)model -{ - ZLShowLivePhotoViewController *vc = [[ZLShowLivePhotoViewController alloc] init]; - vc.model = model; - ZLImageNavigationController *nav = [self getImageNavWithRootVC:vc]; - [self.sender showDetailViewController:nav sender:nil]; -} - -- (void)pushVideoViewControllerWithModel:(ZLPhotoModel *)model -{ - ZLShowVideoViewController *vc = [[ZLShowVideoViewController alloc] init]; - vc.model = model; - ZLImageNavigationController *nav = [self getImageNavWithRootVC:vc]; - [self.sender showDetailViewController:nav sender:nil]; -} - #pragma mark - UIImagePickerControllerDelegate - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { diff --git a/PhotoBrowser/ZLPhotoBrowser.h b/PhotoBrowser/ZLPhotoBrowser.h index 7e349736..a5c92a6c 100644 --- a/PhotoBrowser/ZLPhotoBrowser.h +++ b/PhotoBrowser/ZLPhotoBrowser.h @@ -72,6 +72,12 @@ /**导航条颜色,默认 rgb(19, 153, 231)*/ @property (nonatomic, strong) UIColor *navBarColor; +/**是否在已选择的图片上方覆盖一层已选中遮罩层,默认 NO*/ +@property (nonatomic, assign) BOOL showSelectedMask; + +/**遮罩层颜色,内部会默认调整颜色的透明度为0.2, 默认 blackColor*/ +@property (nonatomic, strong) UIColor *selectedMaskColor; + /**点击确定选择照片回调*/ @property (nonatomic, copy) void (^callSelectImageBlock)(); diff --git a/PhotoBrowser/ZLPhotoBrowser.m b/PhotoBrowser/ZLPhotoBrowser.m index fa50f72f..2c1ace02 100644 --- a/PhotoBrowser/ZLPhotoBrowser.m +++ b/PhotoBrowser/ZLPhotoBrowser.m @@ -57,13 +57,11 @@ - (UIImage *)imageWithColor:(UIColor*)color if (_clipRatios) { return _clipRatios; } else { - return @[ - @{ClippingRatioValue1: @0, ClippingRatioValue2: @0, ClippingRatioTitleFormat: @"Custom"}, - @{ClippingRatioValue1: @1, ClippingRatioValue2: @1, ClippingRatioTitleFormat: @"%g : %g"}, - @{ClippingRatioValue1: @4, ClippingRatioValue2: @3, ClippingRatioTitleFormat: @"%g : %g"}, - @{ClippingRatioValue1: @3, ClippingRatioValue2: @2, ClippingRatioTitleFormat: @"%g : %g"}, - @{ClippingRatioValue1: @16, ClippingRatioValue2: @9, ClippingRatioTitleFormat: @"%g : %g"}, - ]; + return @[GetCustomClipRatio(), + GetClipRatio(1, 1), + GetClipRatio(4, 3), + GetClipRatio(3, 2), + GetClipRatio(16, 9)]; } } diff --git a/PhotoBrowser/ZLShowGifViewController.h b/PhotoBrowser/ZLShowGifViewController.h deleted file mode 100644 index 7fc23aa9..00000000 --- a/PhotoBrowser/ZLShowGifViewController.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// ZLShowGifViewController.h -// ZLPhotoBrowser -// -// Created by long on 17/4/19. -// Copyright © 2017年 long. All rights reserved. -// - -#import - -@class ZLPhotoModel; - -@interface ZLShowGifViewController : UIViewController - -@property (nonatomic, strong) ZLPhotoModel *model; - -@end diff --git a/PhotoBrowser/ZLShowGifViewController.m b/PhotoBrowser/ZLShowGifViewController.m deleted file mode 100644 index a0621a9d..00000000 --- a/PhotoBrowser/ZLShowGifViewController.m +++ /dev/null @@ -1,169 +0,0 @@ -// -// ZLShowGifViewController.m -// ZLPhotoBrowser -// -// Created by long on 17/4/19. -// Copyright © 2017年 long. All rights reserved. -// - -#import "ZLShowGifViewController.h" -#import "ZLDefine.h" -#import "ZLPhotoModel.h" -#import "ZLBigImageCell.h" -#import "ZLPhotoBrowser.h" -#import "ZLPhotoManager.h" -#import "ToastUtils.h" - -@interface ZLShowGifViewController () - -@property (nonatomic, strong) ZLPreviewImageAndGif *bigImageView; -@property (nonatomic, strong) UIView *bottomView; -@property (nonatomic, strong) UILabel *labPhotosBytes; -@property (nonatomic, strong) UIButton *btnDone; -@property (nonatomic, assign) UIStatusBarStyle previousStatusBarStyle; - -@end - -@implementation ZLShowGifViewController - -- (void)dealloc -{ -// NSLog(@"---- %s", __FUNCTION__); -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self initUI]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - self.previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle; - [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - [UIApplication sharedApplication].statusBarStyle = self.previousStatusBarStyle; -} - -- (void)initUI -{ - self.title = [NSBundle zlLocalizedStringForKey:ZLPhotoBrowserGifPreviewText]; - - self.automaticallyAdjustsScrollViewInsets = NO; - self.view.backgroundColor = [UIColor blackColor]; - - //left nav btn - UIImage *navBackImg = GetImageWithName(@"navBackBtn.png"); - - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[navBackImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(btnBack_Click)]; - - self.bigImageView = [[ZLPreviewImageAndGif alloc] initWithFrame:self.view.bounds]; - weakify(self); - self.bigImageView.singleTapCallBack = ^() { - strongify(weakSelf); - if (strongSelf.bottomView.hidden) { - [strongSelf showNavBarAndBottomView]; - } else { - [strongSelf hideNavBarAndBottomView]; - } - }; - [self.bigImageView loadGifImage:self.model.asset]; - [self.view addSubview:self.bigImageView]; - - - self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 44, kViewWidth, 44)]; - self.bottomView.backgroundColor = kBottomView_color; - [self.view addSubview:_bottomView]; - - self.labPhotosBytes = [[UILabel alloc] initWithFrame:CGRectMake(12, 7, 80, 30)]; - self.labPhotosBytes.font = [UIFont systemFontOfSize:15]; - self.labPhotosBytes.textColor = kDoneButton_bgColor; - [self.bottomView addSubview:self.labPhotosBytes]; - - self.btnDone = [UIButton buttonWithType:UIButtonTypeCustom]; - self.btnDone.frame = CGRectMake(kViewWidth - 82, 7, 70, 30); - [self.btnDone setTitle:GetLocalLanguageTextValue(ZLPhotoBrowserDoneText) forState:UIControlStateNormal]; - self.btnDone.titleLabel.font = [UIFont systemFontOfSize:15]; - self.btnDone.layer.masksToBounds = YES; - self.btnDone.layer.cornerRadius = 3.0f; - [self.btnDone setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; - [self.btnDone setBackgroundColor:kDoneButton_bgColor]; - [self.btnDone addTarget:self action:@selector(btnDone_Click:) forControlEvents:UIControlEventTouchUpInside]; - [self.bottomView addSubview:self.btnDone]; - - [ZLPhotoManager getPhotosBytesWithArray:@[self.model] completion:^(NSString *photosBytes) { - strongify(weakSelf); - strongSelf.labPhotosBytes.text = photosBytes; - }]; -} - -- (void)btnBack_Click -{ - UIViewController *vc = [self.navigationController popViewControllerAnimated:YES]; - if (!vc) { - [self.navigationController dismissViewControllerAnimated:YES completion:nil]; - } -} - -- (void)showNavBarAndBottomView -{ - [self.navigationController setNavigationBarHidden:NO animated:YES]; - [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide]; - CGRect frame = _bottomView.frame; - frame.origin.y -= frame.size.height; - _bottomView.hidden = NO; - [UIView animateWithDuration:0.3 animations:^{ - _bottomView.frame = frame; - }]; -} - -- (void)hideNavBarAndBottomView -{ - [self.navigationController setNavigationBarHidden:YES animated:YES]; - [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; - CGRect frame = _bottomView.frame; - frame.origin.y += frame.size.height; - [UIView animateWithDuration:0.3 animations:^{ - _bottomView.frame = frame; - } completion:^(BOOL finished) { - _bottomView.hidden = YES; - }]; -} - -- (void)btnDone_Click:(UIButton *)btn -{ - if (!self.bigImageView.image) { - ShowToastLong(@"%@", GetLocalLanguageTextValue(ZLPhotoBrowserLoadingText)); - return; - } - if (self.navigationController) { - ZLImageNavigationController *nav = (ZLImageNavigationController *)self.navigationController; - if (nav.callSelectGifBlock) { - nav.callSelectGifBlock(self.bigImageView.image, self.model.asset); - } - } else { - [self dismissViewControllerAnimated:YES completion:nil]; - } -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -/* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ - -@end diff --git a/PhotoBrowser/ZLShowLivePhotoViewController.h b/PhotoBrowser/ZLShowLivePhotoViewController.h deleted file mode 100644 index 71a6cb83..00000000 --- a/PhotoBrowser/ZLShowLivePhotoViewController.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// ZLShowLivePhotoViewController.h -// ZLPhotoBrowser -// -// Created by long on 2017/6/17. -// Copyright © 2017年 long. All rights reserved. -// - -#import - -@class ZLPhotoModel; - -@interface ZLShowLivePhotoViewController : UIViewController - -@property (nonatomic, strong) ZLPhotoModel *model; - -@end diff --git a/PhotoBrowser/ZLShowLivePhotoViewController.m b/PhotoBrowser/ZLShowLivePhotoViewController.m deleted file mode 100644 index f847effe..00000000 --- a/PhotoBrowser/ZLShowLivePhotoViewController.m +++ /dev/null @@ -1,186 +0,0 @@ -// -// ZLShowLivePhotoViewController.m -// ZLPhotoBrowser -// -// Created by long on 2017/6/17. -// Copyright © 2017年 long. All rights reserved. -// - -#import "ZLShowLivePhotoViewController.h" -#import -#import "ZLDefine.h" -#import "ZLPhotoManager.h" -#import "ZLPhotoModel.h" -#import "ZLPhotoBrowser.h" - -@interface ZLShowLivePhotoViewController () - -@property (nonatomic, strong) PHLivePhotoView *lpView; - -@property (nonatomic, strong) UIImage *coverImage; -@property (nonatomic, strong) UIView *bottomView; -@property (nonatomic, strong) UILabel *labVideoBytes; -@property (nonatomic, strong) UIButton *btnDone; - -@property (nonatomic, assign) UIStatusBarStyle previousStatusBarStyle; - -@end - -@implementation ZLShowLivePhotoViewController - -- (void)dealloc -{ -// NSLog(@"---- %s", __FUNCTION__); -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.title = [NSBundle zlLocalizedStringForKey:ZLPhotoBrowserLivePhotoPreviewText]; - //left nav btn - UIImage *navBackImg = GetImageWithName(@"navBackBtn.png"); - - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[navBackImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(btnBack_Click)]; - - self.view.backgroundColor = [UIColor blackColor]; - [self requestLivePhoto]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - self.previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle; - [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - [UIApplication sharedApplication].statusBarStyle = self.previousStatusBarStyle; -} - -- (void)btnBack_Click -{ - UIViewController *vc = [self.navigationController popViewControllerAnimated:YES]; - if (!vc) { - [self.navigationController dismissViewControllerAnimated:YES completion:nil]; - } -} - -- (void)requestLivePhoto -{ - weakify(self); - [ZLPhotoManager requestLivePhotoForAsset:self.model.asset completion:^(PHLivePhoto *lv, NSDictionary *info) { - strongify(weakSelf); - if (lv) { - [strongSelf initUI]; - strongSelf.lpView.livePhoto = lv; - [strongSelf.lpView startPlaybackWithStyle:PHLivePhotoViewPlaybackStyleFull]; - } - }]; -} - -- (void)initUI -{ - self.lpView = [[PHLivePhotoView alloc] initWithFrame:self.view.bounds]; - self.lpView.contentMode = UIViewContentModeScaleAspectFit; - [self.view addSubview:self.lpView]; - - self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 44, kViewWidth, 44)]; - self.bottomView.backgroundColor = kBottomView_color; - - [self.view addSubview:_bottomView]; - - self.labVideoBytes = [[UILabel alloc] initWithFrame:CGRectMake(12, 7, 80, 30)]; - self.labVideoBytes.font = [UIFont systemFontOfSize:15]; - self.labVideoBytes.textColor = kDoneButton_bgColor; - [self.bottomView addSubview:self.labVideoBytes]; - - self.btnDone = [UIButton buttonWithType:UIButtonTypeCustom]; - self.btnDone.frame = CGRectMake(kViewWidth - 82, 7, 70, 30); - [self.btnDone setTitle:GetLocalLanguageTextValue(ZLPhotoBrowserDoneText) forState:UIControlStateNormal]; - self.btnDone.titleLabel.font = [UIFont systemFontOfSize:15]; - self.btnDone.layer.masksToBounds = YES; - self.btnDone.layer.cornerRadius = 3.0f; - [self.btnDone setTitleColor:kDoneButton_textColor forState:UIControlStateNormal]; - [self.btnDone setBackgroundColor:kDoneButton_bgColor]; - [self.btnDone addTarget:self action:@selector(btnDone_Click:) forControlEvents:UIControlEventTouchUpInside]; - [self.bottomView addSubview:self.btnDone]; - - UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)]; - [self.view addGestureRecognizer:tap]; - - weakify(self); - [ZLPhotoManager getPhotosBytesWithArray:@[self.model] completion:^(NSString *photosBytes) { - strongify(weakSelf); - strongSelf.labVideoBytes.text = photosBytes; - }]; - [ZLPhotoManager requestOriginalImageForAsset:self.model.asset completion:^(UIImage *image, NSDictionary *info) { - if ([[info objectForKey:PHImageResultIsDegradedKey] boolValue]) return; - strongify(weakSelf); - strongSelf.coverImage = image; - }]; -} - -- (void)btnDone_Click:(UIButton *)btn -{ - if (self.navigationController) { - ZLImageNavigationController *nav = (ZLImageNavigationController *)self.navigationController; - if (nav.callSelectLivePhotoBlock) { - nav.callSelectLivePhotoBlock(self.coverImage, self.model.asset); - } - } else { - [self dismissViewControllerAnimated:YES completion:nil]; - } -} - -- (void)tapAction -{ - if (self.bottomView.hidden) { - [self showNavBarAndBottomView]; - } else { - [self hideNavBarAndBottomView]; - } -} - -- (void)showNavBarAndBottomView -{ - [self.navigationController setNavigationBarHidden:NO animated:YES]; - [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide]; - CGRect frame = _bottomView.frame; - frame.origin.y -= frame.size.height; - _bottomView.hidden = NO; - [UIView animateWithDuration:0.3 animations:^{ - _bottomView.frame = frame; - }]; -} - -- (void)hideNavBarAndBottomView -{ - [self.navigationController setNavigationBarHidden:YES animated:YES]; - [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; - CGRect frame = _bottomView.frame; - frame.origin.y += frame.size.height; - [UIView animateWithDuration:0.3 animations:^{ - _bottomView.frame = frame; - } completion:^(BOOL finished) { - _bottomView.hidden = YES; - }]; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -/* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ - -@end diff --git a/PhotoBrowser/ZLShowVideoViewController.h b/PhotoBrowser/ZLShowVideoViewController.h deleted file mode 100644 index ce27dfbb..00000000 --- a/PhotoBrowser/ZLShowVideoViewController.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// ZLShowVideoViewController.h -// ZLPhotoBrowser -// -// Created by long on 17/4/20. -// Copyright © 2017年 long. All rights reserved. -// - -#import - -@class ZLPhotoModel; - -@interface ZLShowVideoViewController : UIViewController - -@property (nonatomic, strong) ZLPhotoModel *model; - -@end diff --git a/PhotoBrowser/ZLShowVideoViewController.m b/PhotoBrowser/ZLShowVideoViewController.m deleted file mode 100644 index 879f1fa8..00000000 --- a/PhotoBrowser/ZLShowVideoViewController.m +++ /dev/null @@ -1,248 +0,0 @@ -// -// ZLShowVideoViewController.m -// ZLPhotoBrowser -// -// Created by long on 17/4/20. -// Copyright © 2017年 long. All rights reserved. -// - -#import "ZLShowVideoViewController.h" -#import -#import "ZLPhotoModel.h" -#import "ZLDefine.h" -#import "ZLPhotoManager.h" -#import "ZLPhotoBrowser.h" - -@interface ZLShowVideoViewController () - -@property (nonatomic, strong) AVPlayerLayer *playLayer; -@property (nonatomic, strong) UIImage *coverImage; -@property (nonatomic, strong) UIButton *playBtn; -@property (nonatomic, strong) UIView *bottomView; -@property (nonatomic, strong) UIButton *btnDone; - -@property (nonatomic, strong) UILabel *icloudLoadFailedLabel; -@property (nonatomic, assign) UIStatusBarStyle previousStatusBarStyle; -@end - -@implementation ZLShowVideoViewController - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -// NSLog(@"---- %s", __FUNCTION__); -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.title = [NSBundle zlLocalizedStringForKey:ZLPhotoBrowserVideoPreviewText]; - //left nav btn - UIImage *navBackImg = GetImageWithName(@"navBackBtn.png"); - - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[navBackImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(btnBack_Click)]; - - self.view.backgroundColor = [UIColor blackColor]; - [self requestPlayItem]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - self.previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle; - [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - [UIApplication sharedApplication].statusBarStyle = self.previousStatusBarStyle; -} - -- (void)requestPlayItem -{ - if ([ZLPhotoManager judgeAssetisInLocalAblum:self.model.asset]) { - weakify(self); - [ZLPhotoManager requestVideoForAsset:self.model.asset completion:^(AVPlayerItem *item, NSDictionary *info) { - dispatch_async(dispatch_get_main_queue(), ^{ - strongify(weakSelf); - if (!item) { - [strongSelf initVideoLoadFailedFromiCloudUI]; - return; - } - [strongSelf initUI]; - AVPlayer *player = [AVPlayer playerWithPlayerItem:item]; - strongSelf.playLayer.player = player; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:player.currentItem]; - }); - }]; - } else { - [self initVideoLoadFailedFromiCloudUI]; - } -} - -- (void)btnBack_Click -{ - UIViewController *vc = [self.navigationController popViewControllerAnimated:YES]; - if (!vc) { - [self.navigationController dismissViewControllerAnimated:YES completion:nil]; - } -} - -- (void)initUI -{ - self.playLayer = [[AVPlayerLayer alloc] init]; - self.playLayer.frame = self.view.bounds; - [self.view.layer addSublayer:self.playLayer]; - - self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 44, kViewWidth, 44)]; - self.bottomView.backgroundColor = kBottomView_color; - - [self.view addSubview:_bottomView]; - - self.btnDone = [UIButton buttonWithType:UIButtonTypeCustom]; - self.btnDone.frame = CGRectMake(kViewWidth - 82, 7, 70, 30); - [self.btnDone setTitle:GetLocalLanguageTextValue(ZLPhotoBrowserDoneText) forState:UIControlStateNormal]; - self.btnDone.titleLabel.font = [UIFont systemFontOfSize:15]; - self.btnDone.layer.masksToBounds = YES; - self.btnDone.layer.cornerRadius = 3.0f; - [self.btnDone setTitleColor:kDoneButton_textColor forState:UIControlStateNormal]; - [self.btnDone setBackgroundColor:kDoneButton_bgColor]; - [self.btnDone addTarget:self action:@selector(btnDone_Click:) forControlEvents:UIControlEventTouchUpInside]; - [self.bottomView addSubview:self.btnDone]; - - self.playBtn = [UIButton buttonWithType:UIButtonTypeCustom]; - [self.playBtn setBackgroundImage:GetImageWithName(@"playVideo") forState:UIControlStateNormal]; - self.playBtn.frame = CGRectMake(0, 0, 80, 80); - self.playBtn.center = self.view.center; - [self.playBtn addTarget:self action:@selector(playBtnClick) forControlEvents:UIControlEventTouchUpInside]; - [self.view addSubview:self.playBtn]; - - UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playBtnClick)]; - [self.view addGestureRecognizer:tap]; - - weakify(self); - [ZLPhotoManager requestOriginalImageForAsset:self.model.asset completion:^(UIImage *image, NSDictionary *info) { - if ([[info objectForKey:PHImageResultIsDegradedKey] boolValue]) return; - strongify(weakSelf); - strongSelf.coverImage = image; - }]; -} - -- (void)initVideoLoadFailedFromiCloudUI -{ - self.view.backgroundColor = [UIColor blackColor]; - - NSMutableAttributedString *str = [[NSMutableAttributedString alloc] init]; - //创建图片附件 - NSTextAttachment *attach = [[NSTextAttachment alloc]init]; - attach.image = GetImageWithName(@"videoLoadFailed"); - attach.bounds = CGRectMake(0, -10, 30, 30); - //创建属性字符串 通过图片附件 - NSAttributedString *attrStr = [NSAttributedString attributedStringWithAttachment:attach]; - //把NSAttributedString添加到NSMutableAttributedString里面 - [str appendAttributedString:attrStr]; - - NSAttributedString *lastStr = [[NSAttributedString alloc] initWithString:[NSBundle zlLocalizedStringForKey:ZLPhotoBrowseriCloudVideoText]]; - [str appendAttributedString:lastStr]; - self.icloudLoadFailedLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 70, 200, 35)]; - self.icloudLoadFailedLabel.font = [UIFont systemFontOfSize:12]; - self.icloudLoadFailedLabel.attributedText = str; - self.icloudLoadFailedLabel.textColor = [UIColor whiteColor]; - [self.view addSubview:self.icloudLoadFailedLabel]; - - self.playBtn = [UIButton buttonWithType:UIButtonTypeCustom]; - [self.playBtn setBackgroundImage:GetImageWithName(@"playVideo") forState:UIControlStateNormal]; - self.playBtn.frame = CGRectMake(0, 0, 80, 80); - self.playBtn.center = self.view.center; - self.playBtn.enabled = NO; - [self.view addSubview:self.playBtn]; - - UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)]; - [self.view addGestureRecognizer:tap]; -} - -- (void)tapAction -{ - if (self.navigationController.navigationBar.hidden) { - [self showNavBarAndBottomView]; - } else { - [self hideNavBarAndBottomView]; - } -} - -- (void)btnDone_Click:(UIButton *)btn -{ - if (self.navigationController) { - ZLImageNavigationController *nav = (ZLImageNavigationController *)self.navigationController; - if (nav.callSelectVideoBlock) { - nav.callSelectVideoBlock(self.coverImage, self.model.asset); - } - } else { - [self dismissViewControllerAnimated:YES completion:nil]; - } -} - -- (void)playBtnClick -{ - AVPlayer *player = self.playLayer.player; - CMTime stop = player.currentItem.currentTime; - CMTime duration = player.currentItem.duration; - if (player.rate == .0) { - if (stop.value == duration.value) { - [player.currentItem seekToTime:CMTimeMake(0, 1)]; - } - [player play]; - [self hideNavBarAndBottomView]; - } else { - [player pause]; - [self showNavBarAndBottomView]; - } -} - -- (void)playFinished:(AVPlayerItem *)item -{ - [self.playLayer.player seekToTime:kCMTimeZero]; - [self showNavBarAndBottomView]; -} - -- (void)showNavBarAndBottomView -{ - self.playBtn.hidden = NO; - [self.navigationController setNavigationBarHidden:NO animated:YES]; - [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide]; - CGRect frame = _bottomView.frame; - frame.origin.y -= frame.size.height; - [UIView animateWithDuration:0.3 animations:^{ - _bottomView.frame = frame; - }]; -} - -- (void)hideNavBarAndBottomView -{ - self.playBtn.hidden = YES; - [self.navigationController setNavigationBarHidden:YES animated:YES]; - [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; - CGRect frame = _bottomView.frame; - frame.origin.y += frame.size.height; - [UIView animateWithDuration:0.3 animations:^{ - _bottomView.frame = frame; - }]; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -/* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ - -@end diff --git a/PhotoBrowser/ZLThumbnailViewController.m b/PhotoBrowser/ZLThumbnailViewController.m index ac9eb8a8..70595b10 100644 --- a/PhotoBrowser/ZLThumbnailViewController.m +++ b/PhotoBrowser/ZLThumbnailViewController.m @@ -16,9 +16,6 @@ #import "ZLPhotoBrowser.h" #import "ToastUtils.h" #import "ZLProgressHUD.h" -#import "ZLShowGifViewController.h" -#import "ZLShowVideoViewController.h" -#import "ZLShowLivePhotoViewController.h" #import "ZLForceTouchPreviewController.h" #import "ZLEditViewController.h" @@ -29,6 +26,8 @@ @interface ZLThumbnailViewController () *arrDataSources; @@ -102,11 +101,10 @@ - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; - NSLog(@"%f, %f", kViewWidth, kViewHeight); - if (!_isLayoutOK) { [self scrollToBottom]; - } else { + } else if (_switchOrientation) { + _switchOrientation = NO; [self.collectionView scrollToItemAtIndexPath:_visibleIndexPath atScrollPosition:UICollectionViewScrollPositionTop animated:NO]; } } @@ -116,6 +114,7 @@ - (void)deviceOrientationChanged:(NSNotification *)notify { CGPoint pInView = [self.view convertPoint:CGPointMake(0, 70) toView:self.collectionView]; _visibleIndexPath = [self.collectionView indexPathForItemAtPoint:pInView]; + _switchOrientation = YES; } - (BOOL)forceTouchAvailable @@ -381,18 +380,19 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell } } } -// [collectionView reloadItemsAtIndexPaths:[collectionView indexPathsForVisibleItems]]; + + if (weakNav.showSelectedMask) { + strongCell.topView.hidden = !model.isSelected; + } [strongSelf resetBottomBtnsStatus]; }; -//// cell.isSelectedImage = ^BOOL() { -//// strongify(weakSelf); -//// ZLImageNavigationController *nav = (ZLImageNavigationController *)strongSelf.navigationController; -//// return nav.arrSelectedModels.count > 0; -//// }; + cell.allSelectGif = nav.allowSelectGif; cell.allSelectLivePhoto = nav.allowSelectLivePhoto; cell.showSelectBtn = nav.showSelectBtn; cell.cornerRadio = nav.cellCornerRadio; + cell.showMask = nav.showSelectedMask; + cell.maskColor = nav.selectedMaskColor; cell.model = model; return cell; diff --git a/README.md b/README.md index 728f6987..97c7ef75 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,16 @@ - [x] 裁剪图片(可自定义裁剪比例) - [x] 多语言国际化(中文简/繁、英文、日文) - [x] 相册内拍照按钮实时显示镜头捕捉画面 +- [x] 已选择图片遮罩层标记 - [x] 预览已选择照片 -- [x] 自定义圆角弧度 +- [x] 相册内图片自定义圆角弧度 - [x] 自定义升序降序排列 - [x] 多张拍照 ### 更新日志 ``` -● 2.3.2: 新增设置导航颜色api,初步适配横屏,适配iPad; +● 2.3.3: 删除废弃文件,新增在已选择图片上显示遮罩层标记功能; +● 2.3.2: 新增设置导航颜色api,适配横屏,适配iPad; ● 2.2.9: 新增单选模式下选择图片后直接进入编辑界面功能,提供设置裁剪比例api; ● 2.2.8: 更新编辑图片功能,增加裁剪比例选项(1:1, 3:4, 2:3, 9:16,等比例,开发者可根据需求,按照规则自行添加所需比例); ● 2.2.6: ①:可混合选择image、gif、livephoto、video类型; @@ -96,39 +98,54 @@ actionSheet.sender = self; ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/zh-hant.png) - 3DTouch预览效果图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/forceTouch.gif) - 编辑功能预览图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/edit.gif) - 混合选择预览图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/mixSelect.gif) - 横屏预览图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/landscape.gif) +- 遮罩层 + +![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/selectmask.gif) + - 预览快速多选效果图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/预览图快速选择.gif) ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/预览大图快速选择.gif) - 直接进入相册选择相片效果图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/直接进入相册选择相片.gif) - 预览大图及缩放效果图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/查看大图支持缩放.gif) ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/预览选择gif.gif) ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/预览选择视频.gif) - 拍照 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/相册内部拍照.gif) - 相册内混合选择效果图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/相册内混合选择.gif) - 预览已选择照片效果图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/预览已选择照片.gif) ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/预览确定选择的照片.gif) - 原图功能效果图 + ![image](https://github.com/longitachi/ZLPhotoBrowser/blob/master/效果图/原图功能.gif) diff --git a/ZLPhotoBrowser.podspec b/ZLPhotoBrowser.podspec index 7911b111..8857260c 100644 --- a/ZLPhotoBrowser.podspec +++ b/ZLPhotoBrowser.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ZLPhotoBrowser' - s.version = '2.3.2' + s.version = '2.3.3' s.summary = 'An easy way to Multiselect photos,video,gif,livephoto from ablum, force touch to preview image, support portrait and landscape, multiple languages (Chinese, English, Japanese ...)' s.homepage = 'https://github.com/longitachi/ZLPhotoBrowser' s.license = 'MIT' diff --git a/ZLPhotoBrowser.xcodeproj/project.pbxproj b/ZLPhotoBrowser.xcodeproj/project.pbxproj index cc61b47c..e0e05ded 100644 --- a/ZLPhotoBrowser.xcodeproj/project.pbxproj +++ b/ZLPhotoBrowser.xcodeproj/project.pbxproj @@ -38,9 +38,6 @@ FD22D71F1E9E25D1008FCC4E /* ZLPhotoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = FD22D71E1E9E25D1008FCC4E /* ZLPhotoModel.m */; }; FD22D7221E9E2EDC008FCC4E /* ZLPhotoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FD22D7211E9E2EDC008FCC4E /* ZLPhotoManager.m */; }; FD3771191DB8C04B00CAD645 /* NSBundle+ZLPhotoBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = FD3771181DB8C04B00CAD645 /* NSBundle+ZLPhotoBrowser.m */; }; - FD6CFD641F273C6F00E17861 /* ZLShowGifViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FD6CFD5F1F273C6F00E17861 /* ZLShowGifViewController.m */; }; - FD6CFD651F273C6F00E17861 /* ZLShowLivePhotoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FD6CFD611F273C6F00E17861 /* ZLShowLivePhotoViewController.m */; }; - FD6CFD661F273C6F00E17861 /* ZLShowVideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FD6CFD631F273C6F00E17861 /* ZLShowVideoViewController.m */; }; FD7852511EF4FD5300C69E84 /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7852501EF4FD5300C69E84 /* PhotosUI.framework */; }; FD7B52731EFCB81600FB9087 /* ZLEditViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7B52721EFCB81600FB9087 /* ZLEditViewController.m */; }; FD92FA6D1F32B4CE00D7B8C1 /* UIButton+EnlargeTouchArea.m in Sources */ = {isa = PBXBuildFile; fileRef = FD92FA6C1F32B4CE00D7B8C1 /* UIButton+EnlargeTouchArea.m */; }; @@ -100,12 +97,6 @@ FD22D7211E9E2EDC008FCC4E /* ZLPhotoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZLPhotoManager.m; sourceTree = ""; }; FD3771171DB8C04B00CAD645 /* NSBundle+ZLPhotoBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+ZLPhotoBrowser.h"; sourceTree = ""; }; FD3771181DB8C04B00CAD645 /* NSBundle+ZLPhotoBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+ZLPhotoBrowser.m"; sourceTree = ""; }; - FD6CFD5E1F273C6F00E17861 /* ZLShowGifViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZLShowGifViewController.h; sourceTree = ""; }; - FD6CFD5F1F273C6F00E17861 /* ZLShowGifViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZLShowGifViewController.m; sourceTree = ""; }; - FD6CFD601F273C6F00E17861 /* ZLShowLivePhotoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZLShowLivePhotoViewController.h; sourceTree = ""; }; - FD6CFD611F273C6F00E17861 /* ZLShowLivePhotoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZLShowLivePhotoViewController.m; sourceTree = ""; }; - FD6CFD621F273C6F00E17861 /* ZLShowVideoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZLShowVideoViewController.h; sourceTree = ""; }; - FD6CFD631F273C6F00E17861 /* ZLShowVideoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZLShowVideoViewController.m; sourceTree = ""; }; FD7852501EF4FD5300C69E84 /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; FD7B52711EFCB81600FB9087 /* ZLEditViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZLEditViewController.h; sourceTree = ""; }; FD7B52721EFCB81600FB9087 /* ZLEditViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZLEditViewController.m; sourceTree = ""; }; @@ -161,12 +152,6 @@ FD028BAE1CBE33BB009DD2FC /* ZLNoAuthorityViewController.m */, FD028BBB1CBE33BB009DD2FC /* ZLShowBigImgViewController.h */, FD028BBC1CBE33BB009DD2FC /* ZLShowBigImgViewController.m */, - FD6CFD5E1F273C6F00E17861 /* ZLShowGifViewController.h */, - FD6CFD5F1F273C6F00E17861 /* ZLShowGifViewController.m */, - FD6CFD601F273C6F00E17861 /* ZLShowLivePhotoViewController.h */, - FD6CFD611F273C6F00E17861 /* ZLShowLivePhotoViewController.m */, - FD6CFD621F273C6F00E17861 /* ZLShowVideoViewController.h */, - FD6CFD631F273C6F00E17861 /* ZLShowVideoViewController.m */, FD028BBD1CBE33BB009DD2FC /* ZLThumbnailViewController.h */, FD028BBE1CBE33BB009DD2FC /* ZLThumbnailViewController.m */, FDD979E41EF8F35700DD9DA4 /* ZLForceTouchPreviewController.h */, @@ -340,11 +325,9 @@ buildActionMask = 2147483647; files = ( FDD979E61EF8F35700DD9DA4 /* ZLForceTouchPreviewController.m in Sources */, - FD6CFD641F273C6F00E17861 /* ZLShowGifViewController.m in Sources */, FD028BD31CBE33BB009DD2FC /* ToastUtils.m in Sources */, FD028BD51CBE33BB009DD2FC /* ZLBigImageCell.m in Sources */, FD0787281C0D45A200D17B97 /* ViewController.m in Sources */, - FD6CFD661F273C6F00E17861 /* ZLShowVideoViewController.m in Sources */, FD7B52731EFCB81600FB9087 /* ZLEditViewController.m in Sources */, FD028BD71CBE33BB009DD2FC /* ZLNoAuthorityViewController.m in Sources */, FDD979E31EF8C62300DD9DA4 /* ImageCell.m in Sources */, @@ -358,7 +341,6 @@ FD0787221C0D45A200D17B97 /* main.m in Sources */, FD028BDC1CBE33BB009DD2FC /* ZLProgressHUD.m in Sources */, FD028BD81CBE33BB009DD2FC /* ZLPhotoActionSheet.m in Sources */, - FD6CFD651F273C6F00E17861 /* ZLShowLivePhotoViewController.m in Sources */, FD028BDE1CBE33BB009DD2FC /* ZLShowBigImgViewController.m in Sources */, FD22D7221E9E2EDC008FCC4E /* ZLPhotoManager.m in Sources */, FDDB9EBA1E6D2EF6008ED9F1 /* YYWeakProxy.m in Sources */, diff --git a/ZLPhotoBrowser/Base.lproj/Main.storyboard b/ZLPhotoBrowser/Base.lproj/Main.storyboard index c2397b95..7dad167f 100644 --- a/ZLPhotoBrowser/Base.lproj/Main.storyboard +++ b/ZLPhotoBrowser/Base.lproj/Main.storyboard @@ -39,7 +39,7 @@ - + @@ -54,52 +54,52 @@ - + - + - + - + - + @@ -118,19 +118,19 @@ - + @@ -142,7 +142,7 @@ - + @@ -154,7 +154,7 @@ - + - + @@ -191,28 +191,28 @@ - + - + - + - + - + - + @@ -270,7 +270,7 @@ - + + + + + @@ -298,6 +307,7 @@ + @@ -309,7 +319,7 @@ - + @@ -321,7 +331,9 @@ + + @@ -341,6 +353,7 @@ + @@ -371,6 +384,7 @@ + diff --git a/ZLPhotoBrowser/ViewController.m b/ZLPhotoBrowser/ViewController.m index 1d9c3f07..9908aaf1 100644 --- a/ZLPhotoBrowser/ViewController.m +++ b/ZLPhotoBrowser/ViewController.m @@ -12,10 +12,7 @@ #import "ImageCell.h" #import "YYFPSLabel.h" #import -#import "ZLShowGifViewController.h" -#import "ZLShowVideoViewController.h" #import "ZLPhotoModel.h" -#import "ZLShowLivePhotoViewController.h" /////////////////////////////////////////////////// // git 地址: https://github.com/longitachi/ZLPhotoBrowser @@ -35,6 +32,7 @@ @interface ViewController () @property (weak, nonatomic) IBOutlet UISwitch *allowEditSwitch; @property (weak, nonatomic) IBOutlet UISwitch *mixSelectSwitch; @property (weak, nonatomic) IBOutlet UISwitch *editAfterSelectImageSwitch; +@property (weak, nonatomic) IBOutlet UISwitch *maskSwitch; @property (weak, nonatomic) IBOutlet UITextField *previewTextField; @property (weak, nonatomic) IBOutlet UITextField *maxSelCountTextField; @property (weak, nonatomic) IBOutlet UITextField *cornerRadioTextField; @@ -108,7 +106,10 @@ - (ZLPhotoActionSheet *)getPas actionSheet.editAfterSelectThumbnailImage = self.editAfterSelectImageSwitch.isOn; //设置编辑比例 // actionSheet.clipRatios = @[GetClipRatio(4, 3)]; - + //是否在已选择照片上显示遮罩层 + actionSheet.showSelectedMask = self.maskSwitch.isOn; + //遮罩层颜色 +// actionSheet.selectedMaskColor = [UIColor orangeColor]; #pragma required //如果调用的方法没有传sender,则该属性必须提前赋值 actionSheet.sender = self; diff --git "a/\346\225\210\346\236\234\345\233\276/selectmask.gif" "b/\346\225\210\346\236\234\345\233\276/selectmask.gif" new file mode 100644 index 00000000..c4f6108a Binary files /dev/null and "b/\346\225\210\346\236\234\345\233\276/selectmask.gif" differ