Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
dz_TZImagePickerController
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuijing
dz_TZImagePickerController
Commits
d992ff54
Commit
d992ff54
authored
May 20, 2018
by
tanzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
相册和图片cell支持自定义样式的block
parent
8b226a68
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
8 deletions
+39
-8
TZImagePickerController/TZImagePickerController/TZAssetCell.h
...agePickerController/TZImagePickerController/TZAssetCell.h
+5
-5
TZImagePickerController/TZImagePickerController/TZAssetCell.m
...agePickerController/TZImagePickerController/TZAssetCell.m
+16
-0
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+7
-3
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+2
-0
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+2
-0
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+7
-0
No files found.
TZImagePickerController/TZImagePickerController/TZAssetCell.h
View file @
d992ff54
...
...
@@ -19,7 +19,6 @@ typedef enum : NSUInteger {
@class
TZAssetModel
;
@interface
TZAssetCell
:
UICollectionViewCell
@property
(
weak
,
nonatomic
)
UIButton
*
selectPhotoButton
;
@property
(
weak
,
nonatomic
)
UIButton
*
cannotSelectLayerButton
;
@property
(
nonatomic
,
strong
)
TZAssetModel
*
model
;
...
...
@@ -37,21 +36,22 @@ typedef enum : NSUInteger {
@property
(
nonatomic
,
assign
)
BOOL
showSelectBtn
;
@property
(
assign
,
nonatomic
)
BOOL
allowPreview
;
@property
(
assign
,
nonatomic
)
BOOL
useCachedImage
;
@property
(
nonatomic
,
copy
)
void
(
^
assetCellDidSetModelBlock
)(
TZAssetCell
*
cell
,
UIImageView
*
imageView
,
UIImageView
*
selectImageView
,
UILabel
*
indexLabel
,
UIView
*
bottomView
,
UILabel
*
timeLength
,
UIImageView
*
videoImgView
);
@property
(
nonatomic
,
copy
)
void
(
^
assetCellDidLayoutSubviewsBlock
)(
TZAssetCell
*
cell
,
UIImageView
*
imageView
,
UIImageView
*
selectImageView
,
UILabel
*
indexLabel
,
UIView
*
bottomView
,
UILabel
*
timeLength
,
UIImageView
*
videoImgView
);
@end
@class
TZAlbumModel
;
@interface
TZAlbumCell
:
UITableViewCell
@property
(
nonatomic
,
strong
)
TZAlbumModel
*
model
;
@property
(
weak
,
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
);
@end
@interface
TZAssetCameraCell
:
UICollectionViewCell
@property
(
nonatomic
,
strong
)
UIImageView
*
imageView
;
@end
TZImagePickerController/TZImagePickerController/TZAssetCell.m
View file @
d992ff54
...
...
@@ -82,6 +82,10 @@
}
model
.
needOscillatoryAnimation
=
NO
;
[
self
setNeedsLayout
];
if
(
self
.
assetCellDidSetModelBlock
)
{
self
.
assetCellDidSetModelBlock
(
self
,
_imageView
,
_selectImageView
,
_indexLabel
,
_bottomView
,
_timeLength
,
_videoImgView
);
}
}
-
(
void
)
setIndex
:(
NSInteger
)
index
{
...
...
@@ -301,6 +305,10 @@
[
self
.
contentView
bringSubviewToFront
:
_selectPhotoButton
];
[
self
.
contentView
bringSubviewToFront
:
_selectImageView
];
[
self
.
contentView
bringSubviewToFront
:
_indexLabel
];
if
(
self
.
assetCellDidLayoutSubviewsBlock
)
{
self
.
assetCellDidLayoutSubviewsBlock
(
self
,
_imageView
,
_selectImageView
,
_indexLabel
,
_bottomView
,
_timeLength
,
_videoImgView
);
}
}
@end
...
...
@@ -334,6 +342,10 @@
}
else
{
self
.
selectedCountButton
.
hidden
=
YES
;
}
if
(
self
.
albumCellDidSetModelBlock
)
{
self
.
albumCellDidSetModelBlock
(
self
,
_posterImageView
,
_titleLabel
);
}
}
/// For fitting iOS6
...
...
@@ -343,6 +355,10 @@
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
);
}
}
-
(
void
)
layoutSublayersOfLayer
:(
CALayer
*
)
layer
{
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
d992ff54
...
...
@@ -31,6 +31,7 @@
#define iOS9_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f)
#define iOS11Later ([UIDevice currentDevice].systemVersion.floatValue >= 11.0f)
@class
TZAlbumCell
,
TZAssetCell
;
@
protocol
TZImagePickerControllerDelegate
;
@interface
TZImagePickerController
:
UINavigationController
...
...
@@ -163,17 +164,20 @@
@property
(
nonatomic
,
copy
)
void
(
^
cropViewSettingBlock
)(
UIView
*
cropView
);
///< 自定义裁剪框的其他属性
@property
(
nonatomic
,
copy
)
void
(
^
navLeftBarButtonSettingBlock
)(
UIButton
*
leftButton
);
///< 自定义返回按钮样式及其属性
/// 【自定义各页面/组件的样式】在界面初始化完成后调用,允许外界修改样式等
/// 【自定义各页面/组件的样式】在界面初始化
/组件setModel
完成后调用,允许外界修改样式等
@property
(
nonatomic
,
copy
)
void
(
^
photoPickerPageUIConfigBlock
)(
UICollectionView
*
collectionView
,
UIView
*
bottomToolBar
,
UIButton
*
previewButton
,
UIButton
*
originalPhotoButton
,
UILabel
*
originalPhotoLabel
,
UIButton
*
doneButton
,
UIImageView
*
numberImageView
,
UILabel
*
numberLabel
,
UIView
*
divideLine
);
@property
(
nonatomic
,
copy
)
void
(
^
photoPreviewPageUIConfigBlock
)(
UICollectionView
*
collectionView
,
UIView
*
naviBar
,
UIButton
*
backButton
,
UIButton
*
selectButton
,
UILabel
*
indexLabel
,
UIView
*
toolBar
,
UIButton
*
originalPhotoButton
,
UILabel
*
originalPhotoLabel
,
UIButton
*
doneButton
,
UIImageView
*
numberImageView
,
UILabel
*
numberLabel
);
@property
(
nonatomic
,
copy
)
void
(
^
videoPreviewPageUIConfigBlock
)(
UIButton
*
playButton
,
UIView
*
toolBar
,
UIButton
*
doneButton
);
@property
(
nonatomic
,
copy
)
void
(
^
gifPreviewPageUIConfigBlock
)(
UIView
*
toolBar
,
UIButton
*
doneButton
);
/// 【自定义各页面/组件的frame】在界面viewDidLayoutSubviews后调用,允许外界修改尺寸等
@property
(
nonatomic
,
copy
)
void
(
^
assetCellDidSetModelBlock
)(
TZAssetCell
*
cell
,
UIImageView
*
imageView
,
UIImageView
*
selectImageView
,
UILabel
*
indexLabel
,
UIView
*
bottomView
,
UILabel
*
timeLength
,
UIImageView
*
videoImgView
);
@property
(
nonatomic
,
copy
)
void
(
^
albumCellDidSetModelBlock
)(
TZAlbumCell
*
cell
,
UIImageView
*
posterImageView
,
UILabel
*
titleLabel
);
/// 【自定义各页面/组件的frame】在界面viewDidLayoutSubviews/组件layoutSubviews后调用,允许外界修改frame等
@property
(
nonatomic
,
copy
)
void
(
^
photoPickerPageDidLayoutSubviewsBlock
)(
UICollectionView
*
collectionView
,
UIView
*
bottomToolBar
,
UIButton
*
previewButton
,
UIButton
*
originalPhotoButton
,
UILabel
*
originalPhotoLabel
,
UIButton
*
doneButton
,
UIImageView
*
numberImageView
,
UILabel
*
numberLabel
,
UIView
*
divideLine
);
@property
(
nonatomic
,
copy
)
void
(
^
photoPreviewPageDidLayoutSubviewsBlock
)(
UICollectionView
*
collectionView
,
UIView
*
naviBar
,
UIButton
*
backButton
,
UIButton
*
selectButton
,
UILabel
*
indexLabel
,
UIView
*
toolBar
,
UIButton
*
originalPhotoButton
,
UILabel
*
originalPhotoLabel
,
UIButton
*
doneButton
,
UIImageView
*
numberImageView
,
UILabel
*
numberLabel
);
@property
(
nonatomic
,
copy
)
void
(
^
videoPreviewPageDidLayoutSubviewsBlock
)(
UIButton
*
playButton
,
UIView
*
toolBar
,
UIButton
*
doneButton
);
@property
(
nonatomic
,
copy
)
void
(
^
gifPreviewPageDidLayoutSubviewsBlock
)(
UIView
*
toolBar
,
UIButton
*
doneButton
);
@property
(
nonatomic
,
copy
)
void
(
^
assetCellDidLayoutSubviewsBlock
)(
TZAssetCell
*
cell
,
UIImageView
*
imageView
,
UIImageView
*
selectImageView
,
UILabel
*
indexLabel
,
UIView
*
bottomView
,
UILabel
*
timeLength
,
UIImageView
*
videoImgView
);
@property
(
nonatomic
,
copy
)
void
(
^
albumCellDidLayoutSubviewsBlock
)(
TZAlbumCell
*
cell
,
UIImageView
*
posterImageView
,
UILabel
*
titleLabel
);
#pragma mark -
-
(
id
)
showAlertWithTitle
:(
NSString
*
)
title
;
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
d992ff54
...
...
@@ -802,6 +802,8 @@
-
(
UITableViewCell
*
)
tableView
:(
UITableView
*
)
tableView
cellForRowAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
TZAlbumCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:
@"TZAlbumCell"
];
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
cell
.
albumCellDidLayoutSubviewsBlock
=
imagePickerVc
.
albumCellDidLayoutSubviewsBlock
;
cell
.
albumCellDidSetModelBlock
=
imagePickerVc
.
albumCellDidSetModelBlock
;
cell
.
selectedCountButton
.
backgroundColor
=
imagePickerVc
.
iconThemeColor
;
cell
.
model
=
_albumArr
[
indexPath
.
row
];
cell
.
accessoryType
=
UITableViewCellAccessoryDisclosureIndicator
;
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
d992ff54
...
...
@@ -485,6 +485,8 @@ static CGFloat itemMargin = 5;
cell
.
photoDefImage
=
tzImagePickerVc
.
photoDefImage
;
cell
.
photoSelImage
=
tzImagePickerVc
.
photoSelImage
;
cell
.
useCachedImage
=
self
.
useCachedImage
;
cell
.
assetCellDidSetModelBlock
=
tzImagePickerVc
.
assetCellDidSetModelBlock
;
cell
.
assetCellDidLayoutSubviewsBlock
=
tzImagePickerVc
.
assetCellDidLayoutSubviewsBlock
;
TZAssetModel
*
model
;
if
(
tzImagePickerVc
.
sortAscendingByModificationDate
||
!
_showTakePhotoBtn
)
{
model
=
_models
[
indexPath
.
item
];
...
...
TZImagePickerController/ViewController.m
View file @
d992ff54
...
...
@@ -18,6 +18,7 @@
#import "TZPhotoPreviewController.h"
#import "TZGifPhotoPreviewController.h"
#import "TZLocationManager.h"
#import "TZAssetCell.h"
@interface
ViewController
()
<
TZImagePickerControllerDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UIActionSheetDelegate
,
UIImagePickerControllerDelegate
,
UIAlertViewDelegate
,
UINavigationControllerDelegate
>
{
NSMutableArray
*
_selectedPhotos
;
...
...
@@ -259,6 +260,12 @@
[
imagePickerVc
setPhotoPickerPageUIConfigBlock
:
^
(
UICollectionView
*
collectionView
,
UIView
*
bottomToolBar
,
UIButton
*
previewButton
,
UIButton
*
originalPhotoButton
,
UILabel
*
originalPhotoLabel
,
UIButton
*
doneButton
,
UIImageView
*
numberImageView
,
UILabel
*
numberLabel
,
UIView
*
divideLine
)
{
[
doneButton
setTitleColor
:[
UIColor
redColor
]
forState
:
UIControlStateNormal
];
}];
/*
[imagePickerVc setAssetCellDidSetModelBlock:^(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView) {
cell.contentView.clipsToBounds = YES;
cell.contentView.layer.cornerRadius = cell.contentView.tz_width * 0.5;
}];
*/
// 3. Set allow picking video & photo & originalPhoto or not
// 3. 设置是否可以选择视频/图片/原图
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment