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
4ee54c2b
Unverified
Commit
4ee54c2b
authored
May 29, 2019
by
谭真
Committed by
GitHub
May 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1102 from DCLoveNobody/master
UPDATE 裁剪图片图片能等比自适应填充满裁剪区域
parents
cfae6b3f
7726e364
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
4 deletions
+19
-4
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+1
-0
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.h
...erController/TZImagePickerController/TZPhotoPreviewCell.h
+2
-1
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
...erController/TZImagePickerController/TZPhotoPreviewCell.m
+15
-3
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
...roller/TZImagePickerController/TZPhotoPreviewController.m
+1
-0
No files found.
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
4ee54c2b
...
@@ -159,6 +159,7 @@
...
@@ -159,6 +159,7 @@
/// 单选模式,maxImagesCount为1时才生效
/// 单选模式,maxImagesCount为1时才生效
@property
(
nonatomic
,
assign
)
BOOL
showSelectBtn
;
///< 在单选模式下,照片列表页中,显示选择按钮,默认为NO
@property
(
nonatomic
,
assign
)
BOOL
showSelectBtn
;
///< 在单选模式下,照片列表页中,显示选择按钮,默认为NO
@property
(
nonatomic
,
assign
)
BOOL
allowCrop
;
///< 允许裁剪,默认为YES,showSelectBtn为NO才生效
@property
(
nonatomic
,
assign
)
BOOL
allowCrop
;
///< 允许裁剪,默认为YES,showSelectBtn为NO才生效
@property
(
nonatomic
,
assign
)
BOOL
scaleAspectFillCrop
;
///< 是否图片等比缩放填充cropRect区域
@property
(
nonatomic
,
assign
)
CGRect
cropRect
;
///< 裁剪框的尺寸
@property
(
nonatomic
,
assign
)
CGRect
cropRect
;
///< 裁剪框的尺寸
@property
(
nonatomic
,
assign
)
CGRect
cropRectPortrait
;
///< 裁剪框的尺寸(竖屏)
@property
(
nonatomic
,
assign
)
CGRect
cropRectPortrait
;
///< 裁剪框的尺寸(竖屏)
@property
(
nonatomic
,
assign
)
CGRect
cropRectLandscape
;
///< 裁剪框的尺寸(横屏)
@property
(
nonatomic
,
assign
)
CGRect
cropRectLandscape
;
///< 裁剪框的尺寸(横屏)
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.h
View file @
4ee54c2b
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
@property
(
nonatomic
,
assign
)
BOOL
allowCrop
;
@property
(
nonatomic
,
assign
)
BOOL
allowCrop
;
@property
(
nonatomic
,
assign
)
CGRect
cropRect
;
@property
(
nonatomic
,
assign
)
CGRect
cropRect
;
@property
(
nonatomic
,
assign
)
BOOL
scaleAspectFillCrop
;
-
(
void
)
recoverSubviews
;
-
(
void
)
recoverSubviews
;
...
@@ -40,7 +41,7 @@
...
@@ -40,7 +41,7 @@
@property
(
nonatomic
,
assign
)
BOOL
allowCrop
;
@property
(
nonatomic
,
assign
)
BOOL
allowCrop
;
@property
(
nonatomic
,
assign
)
CGRect
cropRect
;
@property
(
nonatomic
,
assign
)
CGRect
cropRect
;
@property
(
nonatomic
,
assign
)
BOOL
scaleAspectFillCrop
;
@property
(
nonatomic
,
strong
)
TZAssetModel
*
model
;
@property
(
nonatomic
,
strong
)
TZAssetModel
*
model
;
@property
(
nonatomic
,
strong
)
id
asset
;
@property
(
nonatomic
,
strong
)
id
asset
;
@property
(
nonatomic
,
copy
)
void
(
^
singleTapGestureBlock
)(
void
);
@property
(
nonatomic
,
copy
)
void
(
^
singleTapGestureBlock
)(
void
);
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
View file @
4ee54c2b
...
@@ -78,6 +78,11 @@
...
@@ -78,6 +78,11 @@
_previewView
.
allowCrop
=
allowCrop
;
_previewView
.
allowCrop
=
allowCrop
;
}
}
-
(
void
)
setScaleAspectFillCrop
:(
BOOL
)
scaleAspectFillCrop
{
_scaleAspectFillCrop
=
scaleAspectFillCrop
;
_previewView
.
scaleAspectFillCrop
=
scaleAspectFillCrop
;
}
-
(
void
)
setCropRect
:(
CGRect
)
cropRect
{
-
(
void
)
setCropRect
:(
CGRect
)
cropRect
{
_cropRect
=
cropRect
;
_cropRect
=
cropRect
;
_previewView
.
cropRect
=
cropRect
;
_previewView
.
cropRect
=
cropRect
;
...
@@ -201,7 +206,14 @@
...
@@ -201,7 +206,14 @@
self
.
imageRequestID
=
[[
TZImageManager
manager
]
getPhotoWithAsset
:
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
)
{
self
.
imageRequestID
=
[[
TZImageManager
manager
]
getPhotoWithAsset
:
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
)
{
if
(
!
[
asset
isEqual
:
self
->
_asset
])
return
;
if
(
!
[
asset
isEqual
:
self
->
_asset
])
return
;
self
.
imageView
.
image
=
photo
;
self
.
imageView
.
image
=
photo
;
CGFloat
scale
=
MAX
(
self
.
cropRect
.
size
.
width
/
self
.
imageView
.
tz_width
,
self
.
cropRect
.
size
.
height
/
self
.
imageView
.
tz_height
);
[
self
resizeSubviews
];
[
self
resizeSubviews
];
if
(
self
.
scaleAspectFillCrop
&&
scale
>
1
)
{
// 如果设置图片缩放裁剪并且图片需要缩放
self
.
scrollView
.
minimumZoomScale
=
scale
;
self
.
scrollView
.
maximumZoomScale
=
scale
*
2
;
[
self
.
scrollView
setZoomScale
:
scale
animated
:
YES
];
}
self
->
_progressView
.
hidden
=
YES
;
self
->
_progressView
.
hidden
=
YES
;
if
(
self
.
imageProgressUpdateBlock
)
{
if
(
self
.
imageProgressUpdateBlock
)
{
self
.
imageProgressUpdateBlock
(
1
);
self
.
imageProgressUpdateBlock
(
1
);
...
@@ -229,7 +241,7 @@
...
@@ -229,7 +241,7 @@
}
}
-
(
void
)
recoverSubviews
{
-
(
void
)
recoverSubviews
{
[
_scrollView
setZoomScale
:
1
.
0
animated
:
NO
];
[
_scrollView
setZoomScale
:
_scrollView
.
minimumZoomScale
animated
:
NO
];
[
self
resizeSubviews
];
[
self
resizeSubviews
];
}
}
...
@@ -305,9 +317,9 @@
...
@@ -305,9 +317,9 @@
#pragma mark - UITapGestureRecognizer Event
#pragma mark - UITapGestureRecognizer Event
-
(
void
)
doubleTap
:(
UITapGestureRecognizer
*
)
tap
{
-
(
void
)
doubleTap
:(
UITapGestureRecognizer
*
)
tap
{
if
(
_scrollView
.
zoomScale
>
1
.
0
)
{
if
(
_scrollView
.
zoomScale
>
_scrollView
.
minimumZoomScale
)
{
_scrollView
.
contentInset
=
UIEdgeInsetsZero
;
_scrollView
.
contentInset
=
UIEdgeInsetsZero
;
[
_scrollView
setZoomScale
:
1
.
0
animated
:
YES
];
[
_scrollView
setZoomScale
:
_scrollView
.
minimumZoomScale
animated
:
YES
];
}
else
{
}
else
{
CGPoint
touchPoint
=
[
tap
locationInView
:
self
.
imageView
];
CGPoint
touchPoint
=
[
tap
locationInView
:
self
.
imageView
];
CGFloat
newZoomScale
=
_scrollView
.
maximumZoomScale
;
CGFloat
newZoomScale
=
_scrollView
.
maximumZoomScale
;
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
View file @
4ee54c2b
...
@@ -464,6 +464,7 @@
...
@@ -464,6 +464,7 @@
TZPhotoPreviewCell
*
photoPreviewCell
=
(
TZPhotoPreviewCell
*
)
cell
;
TZPhotoPreviewCell
*
photoPreviewCell
=
(
TZPhotoPreviewCell
*
)
cell
;
photoPreviewCell
.
cropRect
=
_tzImagePickerVc
.
cropRect
;
photoPreviewCell
.
cropRect
=
_tzImagePickerVc
.
cropRect
;
photoPreviewCell
.
allowCrop
=
_tzImagePickerVc
.
allowCrop
;
photoPreviewCell
.
allowCrop
=
_tzImagePickerVc
.
allowCrop
;
photoPreviewCell
.
scaleAspectFillCrop
=
_tzImagePickerVc
.
scaleAspectFillCrop
;
__weak
typeof
(
_tzImagePickerVc
)
weakTzImagePickerVc
=
_tzImagePickerVc
;
__weak
typeof
(
_tzImagePickerVc
)
weakTzImagePickerVc
=
_tzImagePickerVc
;
__weak
typeof
(
_collectionView
)
weakCollectionView
=
_collectionView
;
__weak
typeof
(
_collectionView
)
weakCollectionView
=
_collectionView
;
__weak
typeof
(
photoPreviewCell
)
weakCell
=
photoPreviewCell
;
__weak
typeof
(
photoPreviewCell
)
weakCell
=
photoPreviewCell
;
...
...
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