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

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

parent 4e381ea8
...@@ -110,10 +110,12 @@ ...@@ -110,10 +110,12 @@
@property (nonatomic, assign) BOOL isStatusBarDefault; @property (nonatomic, assign) BOOL isStatusBarDefault;
/// Single selection mode, valid when maxImagesCount = 1 /// Single selection mode, valid when maxImagesCount = 1
/// 单选模式,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) CGRect cropRect; ///< 裁剪框的尺寸 @property (nonatomic, assign) CGRect cropRect; ///< 裁剪框的尺寸
@property (nonatomic, assign) BOOL needCircleCrop; ///< 需要圆形裁剪框 @property (nonatomic, assign) CGRect cropRectPortrait; ///< 裁剪框的尺寸(竖屏)
@property (nonatomic, assign) CGRect cropRectLandscape; ///< 裁剪框的尺寸(横屏)
@property (nonatomic, assign) BOOL needCircleCrop; ///< 需要圆形裁剪框
@property (nonatomic, assign) NSInteger circleCropRadius; ///< 圆形裁剪框半径大小 @property (nonatomic, assign) NSInteger circleCropRadius; ///< 圆形裁剪框半径大小
@property (nonatomic, copy) void (^cropViewSettingBlock)(UIView *cropView); ///< 自定义裁剪框的其他属性 @property (nonatomic, copy) void (^cropViewSettingBlock)(UIView *cropView); ///< 自定义裁剪框的其他属性
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
self.navigationBar.tintColor = [UIColor whiteColor]; self.navigationBar.tintColor = [UIColor whiteColor];
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
if (!TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO; if (!TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
} }
} }
- (void)setNaviBgColor:(UIColor *)naviBgColor { - (void)setNaviBgColor:(UIColor *)naviBgColor {
...@@ -237,6 +237,9 @@ ...@@ -237,6 +237,9 @@
[self configDefaultImageName]; [self configDefaultImageName];
[self configDefaultBtnTitle]; [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 { - (void)configDefaultImageName {
...@@ -378,15 +381,14 @@ ...@@ -378,15 +381,14 @@
- (void)setCircleCropRadius:(NSInteger)circleCropRadius { - (void)setCircleCropRadius:(NSInteger)circleCropRadius {
_circleCropRadius = 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 { - (void)setCropRect:(CGRect)cropRect {
if (_cropRect.size.width > 0) { _cropRect = cropRect;
return _cropRect; _cropRectPortrait = cropRect;
} CGFloat widthHeight = cropRect.size.width;
CGFloat cropViewWH = MIN(self.view.tz_width, self.view.tz_height) / 3 * 2; _cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, cropRect.origin.x, widthHeight, widthHeight);
return CGRectMake((self.view.tz_width - cropViewWH) / 2, (self.view.tz_height - cropViewWH) / 2, cropViewWH, cropViewWH);
} }
- (void)setTimeout:(NSInteger)timeout { - (void)setTimeout:(NSInteger)timeout {
...@@ -503,21 +505,29 @@ ...@@ -503,21 +505,29 @@
#pragma mark - UIContentContainer #pragma mark - UIContentContainer
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
if (![UIApplication sharedApplication].statusBarHidden) { [self willInterfaceOrientionChange];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ if (size.width > size.height) {
if (iOS7Later && !TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO; _cropRect = _cropRectLandscape;
}); } else {
_cropRect = _cropRectPortrait;
} }
self.cropRect = CGRectZero;
} }
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (![UIApplication sharedApplication].statusBarHidden) { [self willInterfaceOrientionChange];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ if (toInterfaceOrientation >= 3) {
if (iOS7Later && !TZ_isGlobalHideStatusBar) [UIApplication sharedApplication].statusBarHidden = NO; _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 #pragma mark - Layout
......
...@@ -302,9 +302,7 @@ static CGFloat itemMargin = 5; ...@@ -302,9 +302,7 @@ static CGFloat itemMargin = 5;
_divideLine.frame = CGRectMake(0, 0, self.view.tz_width, 1); _divideLine.frame = CGRectMake(0, 0, self.view.tz_width, 1);
[TZImageManager manager].columnNumber = [TZImageManager manager].columnNumber; [TZImageManager manager].columnNumber = [TZImageManager manager].columnNumber;
if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { [self.collectionView reloadData];
[self.collectionView reloadData];
}
} }
#pragma mark - Notification #pragma mark - Notification
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:self.maxCountTF.text.integerValue columnNumber:self.columnNumberTF.text.integerValue delegate:self pushPhotoPickerVc:YES]; TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:self.maxCountTF.text.integerValue columnNumber:self.columnNumberTF.text.integerValue delegate:self pushPhotoPickerVc:YES];
// imagePickerVc.navigationBar.translucent = NO; // imagePickerVc.navigationBar.translucent = NO;
#pragma mark - 类个性化设置,这些参数都可以不传,此时会走默认设置 #pragma mark - 类个性化设置,这些参数都可以不传,此时会走默认设置
imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto; imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
if (self.maxCountTF.text.integerValue > 1) { if (self.maxCountTF.text.integerValue > 1) {
...@@ -262,8 +262,13 @@ ...@@ -262,8 +262,13 @@
imagePickerVc.showSelectBtn = NO; imagePickerVc.showSelectBtn = NO;
imagePickerVc.allowCrop = self.allowCropSwitch.isOn; imagePickerVc.allowCrop = self.allowCropSwitch.isOn;
imagePickerVc.needCircleCrop = self.needCircleCropSwitch.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) { [imagePickerVc setCropViewSettingBlock:^(UIView *cropView) {
cropView.layer.borderColor = [UIColor redColor].CGColor; cropView.layer.borderColor = [UIColor redColor].CGColor;
...@@ -271,6 +276,8 @@ ...@@ -271,6 +276,8 @@
}];*/ }];*/
//imagePickerVc.allowPreview = NO; //imagePickerVc.allowPreview = NO;
imagePickerVc.isStatusBarDefault = NO;
#pragma mark - 到这里为止 #pragma mark - 到这里为止
// You can get the photos by block, the same as by delegate. // 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