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
fe1a8db8
Commit
fe1a8db8
authored
Jul 22, 2017
by
yuzheng.tz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
允许设置横屏下的裁剪框尺寸cropRectLandscape
parent
4e381ea8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
28 deletions
+45
-28
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+6
-4
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+28
-18
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+1
-3
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+10
-3
No files found.
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
fe1a8db8
...
...
@@ -113,6 +113,8 @@
@property
(
nonatomic
,
assign
)
BOOL
showSelectBtn
;
///< 在单选模式下,照片列表页中,显示选择按钮,默认为NO
@property
(
nonatomic
,
assign
)
BOOL
allowCrop
;
///< 允许裁剪,默认为YES,showSelectBtn为NO才生效
@property
(
nonatomic
,
assign
)
CGRect
cropRect
;
///< 裁剪框的尺寸
@property
(
nonatomic
,
assign
)
CGRect
cropRectPortrait
;
///< 裁剪框的尺寸(竖屏)
@property
(
nonatomic
,
assign
)
CGRect
cropRectLandscape
;
///< 裁剪框的尺寸(横屏)
@property
(
nonatomic
,
assign
)
BOOL
needCircleCrop
;
///< 需要圆形裁剪框
@property
(
nonatomic
,
assign
)
NSInteger
circleCropRadius
;
///< 圆形裁剪框半径大小
@property
(
nonatomic
,
copy
)
void
(
^
cropViewSettingBlock
)(
UIView
*
cropView
);
///< 自定义裁剪框的其他属性
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
fe1a8db8
...
...
@@ -237,6 +237,9 @@
[
self
configDefaultImageName
];
[
self
configDefaultBtnTitle
];
CGFloat
cropViewWH
=
MIN
(
self
.
view
.
tz_width
,
self
.
view
.
tz_height
)
/
3
*
2
;
self
.
cropRect
=
CGRectMake
((
self
.
view
.
tz_width
-
cropViewWH
)
/
2
,
(
self
.
view
.
tz_height
-
cropViewWH
)
/
2
,
cropViewWH
,
cropViewWH
);
}
-
(
void
)
configDefaultImageName
{
...
...
@@ -378,15 +381,14 @@
-
(
void
)
setCircleCropRadius
:(
NSInteger
)
circleCropRadius
{
_circleCropRadius
=
circleCropRadius
;
_
cropRect
=
CGRectMake
(
self
.
view
.
tz_width
/
2
-
circleCropRadius
,
self
.
view
.
tz_height
/
2
-
_circleCropRadius
,
_circleCropRadius
*
2
,
_circleCropRadius
*
2
);
self
.
cropRect
=
CGRectMake
(
self
.
view
.
tz_width
/
2
-
circleCropRadius
,
self
.
view
.
tz_height
/
2
-
_circleCropRadius
,
_circleCropRadius
*
2
,
_circleCropRadius
*
2
);
}
-
(
CGRect
)
cropRect
{
if
(
_cropRect
.
size
.
width
>
0
)
{
return
_cropRect
;
}
CGFloat
cropViewWH
=
MIN
(
self
.
view
.
tz_width
,
self
.
view
.
tz_height
)
/
3
*
2
;
return
CGRectMake
((
self
.
view
.
tz_width
-
cropViewWH
)
/
2
,
(
self
.
view
.
tz_height
-
cropViewWH
)
/
2
,
cropViewWH
,
cropViewWH
);
-
(
void
)
setCropRect
:(
CGRect
)
cropRect
{
_cropRect
=
cropRect
;
_cropRectPortrait
=
cropRect
;
CGFloat
widthHeight
=
cropRect
.
size
.
width
;
_cropRectLandscape
=
CGRectMake
((
self
.
view
.
tz_height
-
widthHeight
)
/
2
,
cropRect
.
origin
.
x
,
widthHeight
,
widthHeight
);
}
-
(
void
)
setTimeout
:(
NSInteger
)
timeout
{
...
...
@@ -503,21 +505,29 @@
#pragma mark - UIContentContainer
-
(
void
)
viewWillTransitionToSize
:(
CGSize
)
size
withTransitionCoordinator
:(
id
<
UIViewControllerTransitionCoordinator
>
)
coordinator
{
if
(
!
[
UIApplication
sharedApplication
].
statusBarHidden
)
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
.
01
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
(
iOS7Later
&&
!
TZ_isGlobalHideStatusBar
)
[
UIApplication
sharedApplication
].
statusBarHidden
=
NO
;
});
[
self
willInterfaceOrientionChange
];
if
(
size
.
width
>
size
.
height
)
{
_cropRect
=
_cropRectLandscape
;
}
else
{
_cropRect
=
_cropRectPortrait
;
}
self
.
cropRect
=
CGRectZero
;
}
-
(
void
)
willAnimateRotationToInterfaceOrientation
:(
UIInterfaceOrientation
)
toInterfaceOrientation
duration
:(
NSTimeInterval
)
duration
{
[
self
willInterfaceOrientionChange
];
if
(
toInterfaceOrientation
>=
3
)
{
_cropRect
=
_cropRectLandscape
;
}
else
{
_cropRect
=
_cropRectPortrait
;
}
}
-
(
void
)
willInterfaceOrientionChange
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
.
02
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
(
!
[
UIApplication
sharedApplication
].
statusBarHidden
)
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
.
01
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
(
iOS7Later
&&
!
TZ_isGlobalHideStatusBar
)
[
UIApplication
sharedApplication
].
statusBarHidden
=
NO
;
});
}
self
.
cropRect
=
CGRectZero
;
})
;
}
#pragma mark - Layout
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
fe1a8db8
...
...
@@ -302,9 +302,7 @@ static CGFloat itemMargin = 5;
_divideLine
.
frame
=
CGRectMake
(
0
,
0
,
self
.
view
.
tz_width
,
1
);
[
TZImageManager
manager
].
columnNumber
=
[
TZImageManager
manager
].
columnNumber
;
if
([
UIApplication
sharedApplication
].
statusBarOrientation
==
UIInterfaceOrientationLandscapeLeft
||
[
UIApplication
sharedApplication
].
statusBarOrientation
==
UIInterfaceOrientationLandscapeRight
)
{
[
self
.
collectionView
reloadData
];
}
}
#pragma mark - Notification
...
...
TZImagePickerController/ViewController.m
View file @
fe1a8db8
...
...
@@ -222,7 +222,7 @@
TZImagePickerController
*
imagePickerVc
=
[[
TZImagePickerController
alloc
]
initWithMaxImagesCount
:
self
.
maxCountTF
.
text
.
integerValue
columnNumber
:
self
.
columnNumberTF
.
text
.
integerValue
delegate
:
self
pushPhotoPickerVc
:
YES
];
// imagePickerVc.navigationBar.translucent = NO;
#pragma mark -
四
类个性化设置,这些参数都可以不传,此时会走默认设置
#pragma mark -
五
类个性化设置,这些参数都可以不传,此时会走默认设置
imagePickerVc
.
isSelectOriginalPhoto
=
_isSelectOriginalPhoto
;
if
(
self
.
maxCountTF
.
text
.
integerValue
>
1
)
{
...
...
@@ -262,8 +262,13 @@
imagePickerVc
.
showSelectBtn
=
NO
;
imagePickerVc
.
allowCrop
=
self
.
allowCropSwitch
.
isOn
;
imagePickerVc
.
needCircleCrop
=
self
.
needCircleCropSwitch
.
isOn
;
imagePickerVc
.
circleCropRadius
=
100
;
imagePickerVc
.
isStatusBarDefault
=
NO
;
// 设置竖屏下的裁剪尺寸
NSInteger
left
=
30
;
NSInteger
widthHeight
=
self
.
view
.
tz_width
-
2
*
left
;
NSInteger
top
=
(
self
.
view
.
tz_height
-
widthHeight
)
/
2
;
imagePickerVc
.
cropRect
=
CGRectMake
(
left
,
top
,
widthHeight
,
widthHeight
);
// 设置横屏下的裁剪尺寸
// imagePickerVc.cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, left, widthHeight, widthHeight);
/*
[imagePickerVc setCropViewSettingBlock:^(UIView *cropView) {
cropView.layer.borderColor = [UIColor redColor].CGColor;
...
...
@@ -271,6 +276,8 @@
}];*/
//imagePickerVc.allowPreview = NO;
imagePickerVc
.
isStatusBarDefault
=
NO
;
#pragma mark - 到这里为止
// You can get the photos by block, the same as by delegate.
...
...
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