Commit 514b8aae authored by yuzheng.tz's avatar yuzheng.tz

新增showPhotoCannotSelectLayer属性,当已选照片张数达到最大可选张数时,可像微信一样让其它照片显示一个浮层

parent 66f70eb1
......@@ -21,6 +21,7 @@ typedef enum : NSUInteger {
@interface TZAssetCell : UICollectionViewCell
@property (weak, nonatomic) UIButton *selectPhotoButton;
@property (weak, nonatomic) UIButton *cannotSelectLayerButton;
@property (nonatomic, strong) TZAssetModel *model;
@property (assign, nonatomic) NSInteger index;
@property (nonatomic, copy) void (^didSelectPhotoBlock)(BOOL);
......
......@@ -190,9 +190,6 @@
imageView.clipsToBounds = YES;
[self.contentView addSubview:imageView];
_imageView = imageView;
[self.contentView bringSubviewToFront:_selectImageView];
[self.contentView bringSubviewToFront:_bottomView];
}
return _imageView;
}
......@@ -219,6 +216,15 @@
return _bottomView;
}
- (UIButton *)cannotSelectLayerButton {
if (_cannotSelectLayerButton == nil) {
UIButton *cannotSelectLayerButton = [[UIButton alloc] init];
[self.contentView addSubview:cannotSelectLayerButton];
_cannotSelectLayerButton = cannotSelectLayerButton;
}
return _cannotSelectLayerButton;
}
- (UIImageView *)videoImgView {
if (_videoImgView == nil) {
UIImageView *videoImgView = [[UIImageView alloc] init];
......@@ -264,6 +270,7 @@
- (void)layoutSubviews {
[super layoutSubviews];
_cannotSelectLayerButton.frame = self.bounds;
if (self.allowPreview) {
_selectPhotoButton.frame = CGRectMake(self.tz_width - 44, 0, 44, 44);
} else {
......@@ -288,6 +295,12 @@
self.type = (NSInteger)self.model.type;
self.showSelectBtn = self.showSelectBtn;
[self.contentView bringSubviewToFront:_bottomView];
[self.contentView bringSubviewToFront:_cannotSelectLayerButton];
[self.contentView bringSubviewToFront:_selectPhotoButton];
[self.contentView bringSubviewToFront:_selectImageView];
[self.contentView bringSubviewToFront:_indexLabel];
}
@end
......
......@@ -122,6 +122,12 @@
/// 默认为NO,如果设置为YES,会显示照片的选中序号
@property (assign, nonatomic) BOOL showSelectedIndex;
/// Default is NO, if set YES, when selected photos's count up to maxImagesCount, other photo will show float layer what's color is cannotSelectLayerColor.
/// 默认是NO,如果设置为YES,当照片选择张数达到maxImagesCount时,其它照片会显示颜色为cannotSelectLayerColor的浮层
@property (assign, nonatomic) BOOL showPhotoCannotSelectLayer;
/// Default is white color with 0.8 alpha;
@property (strong, nonatomic) UIColor *cannotSelectLayerColor;
/// The photos user have selected
/// 用户选中过的图片数组
@property (nonatomic, strong) NSMutableArray *selectedAssets;
......
......@@ -277,6 +277,7 @@
self.barItemTextColor = [UIColor whiteColor];
self.allowPreview = YES;
self.statusBarStyle = UIStatusBarStyleLightContent;
self.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
self.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
[self configDefaultBtnTitle];
......
......@@ -492,6 +492,13 @@ static CGFloat itemMargin = 5;
cell.showSelectBtn = tzImagePickerVc.showSelectBtn;
cell.allowPreview = tzImagePickerVc.allowPreview;
if (tzImagePickerVc.selectedModels.count >= tzImagePickerVc.maxImagesCount && tzImagePickerVc.showPhotoCannotSelectLayer && !model.isSelected) {
cell.cannotSelectLayerButton.backgroundColor = tzImagePickerVc.cannotSelectLayerColor;
cell.cannotSelectLayerButton.hidden = NO;
} else {
cell.cannotSelectLayerButton.hidden = YES;
}
__weak typeof(cell) weakCell = cell;
__weak typeof(self) weakSelf = self;
__weak typeof(_numberImageView.layer) weakLayer = _numberImageView.layer;
......@@ -515,6 +522,7 @@ static CGFloat itemMargin = 5;
if (tzImagePickerVc.showSelectedIndex) {
[strongSelf setUseCachedImageAndReloadData];
}
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
} else {
// 2. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
if (tzImagePickerVc.selectedModels.count < tzImagePickerVc.maxImagesCount) {
......@@ -526,12 +534,15 @@ static CGFloat itemMargin = 5;
}
[tzImagePickerVc addSelectedModel:model];
[strongSelf refreshBottomToolBarStatus];
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
} else {
NSString *title = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Select a maximum of %zd photos"], tzImagePickerVc.maxImagesCount];
[tzImagePickerVc showAlertWithTitle:title];
}
}
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
if (tzImagePickerVc.showPhotoCannotSelectLayer && !tzImagePickerVc.showSelectedIndex) {
[strongSelf.collectionView reloadData];
}
};
return cell;
}
......
......@@ -250,7 +250,9 @@
// imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
// imagePickerVc.oKButtonTitleColorNormal = [UIColor greenColor];
// imagePickerVc.navigationBar.translucent = NO;
imagePickerVc.iconThemeColor = [UIColor redColor];
imagePickerVc.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
imagePickerVc.showPhotoCannotSelectLayer = YES;
imagePickerVc.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
// 3. Set allow picking video & photo & originalPhoto or not
// 3. 设置是否可以选择视频/图片/原图
......
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