Commit fe1a8db8 authored by yuzheng.tz's avatar yuzheng.tz

允许设置横屏下的裁剪框尺寸cropRectLandscape

parent 4e381ea8
......@@ -110,10 +110,12 @@
@property (nonatomic, assign) BOOL isStatusBarDefault;
/// Single selection mode, valid when maxImagesCount = 1
/// 单选模式,maxImagesCount为1时才生效
@property (nonatomic, assign) BOOL showSelectBtn; ///< 在单选模式下,照片列表页中,显示选择按钮,默认为NO
@property (nonatomic, assign) BOOL allowCrop; ///< 允许裁剪,默认为YES,showSelectBtn为NO才生效
@property (nonatomic, assign) CGRect cropRect; ///< 裁剪框的尺寸
@property (nonatomic, assign) BOOL needCircleCrop; ///< 需要圆形裁剪框
@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); ///< 自定义裁剪框的其他属性
......
......@@ -55,7 +55,7 @@
self.navigationBar.tintColor = [UIColor whiteColor];
self.automaticallyAdjustsScrollViewInsets = NO;
if (!TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
}
}
}
- (void)setNaviBgColor:(UIColor *)naviBgColor {
......@@ -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 {
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 (toInterfaceOrientation >= 3) {
_cropRect = _cropRectLandscape;
} else {
_cropRect = _cropRectPortrait;
}
self.cropRect = CGRectZero;
}
- (void)willInterfaceOrientionChange {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.02 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (![UIApplication sharedApplication].statusBarHidden) {
if (iOS7Later && !TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
}
});
}
#pragma mark - Layout
......
......@@ -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];
}
[self.collectionView reloadData];
}
#pragma mark - Notification
......
......@@ -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.
......
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