Commit b6fc9da2 authored by yuzheng's avatar yuzheng

支持横屏状态下进入裁剪模式

parent c9044927
...@@ -353,6 +353,7 @@ ...@@ -353,6 +353,7 @@
@interface TZCommonTools : NSObject @interface TZCommonTools : NSObject
+ (UIEdgeInsets)tz_safeAreaInsets; + (UIEdgeInsets)tz_safeAreaInsets;
+ (BOOL)tz_isIPhoneX; + (BOOL)tz_isIPhoneX;
+ (BOOL)tz_isLandscape;
+ (CGFloat)tz_statusBarHeight; + (CGFloat)tz_statusBarHeight;
// 获得Info.plist数据字典 // 获得Info.plist数据字典
+ (NSDictionary *)tz_getInfoDictionary; + (NSDictionary *)tz_getInfoDictionary;
......
...@@ -521,9 +521,15 @@ ...@@ -521,9 +521,15 @@
- (void)setCropRect:(CGRect)cropRect { - (void)setCropRect:(CGRect)cropRect {
_cropRect = cropRect; _cropRect = cropRect;
if ([TZCommonTools tz_isLandscape]) {
_cropRectLandscape = cropRect;
CGFloat widthHeight = cropRect.size.height;
_cropRectPortrait = CGRectMake(cropRect.origin.y, (self.view.tz_width - widthHeight) / 2, widthHeight, widthHeight);
} else {
_cropRectPortrait = cropRect; _cropRectPortrait = cropRect;
CGFloat widthHeight = cropRect.size.width; CGFloat widthHeight = cropRect.size.width;
_cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, cropRect.origin.x, widthHeight, widthHeight); _cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, cropRect.origin.x, widthHeight, widthHeight);
}
} }
- (CGRect)cropRect { - (CGRect)cropRect {
...@@ -955,6 +961,14 @@ ...@@ -955,6 +961,14 @@
CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(926, 428))); CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(926, 428)));
} }
+ (BOOL)tz_isLandscape {
if ([UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeRight ||
[UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeLeft) {
return true;
}
return false;
}
+ (CGFloat)tz_statusBarHeight { + (CGFloat)tz_statusBarHeight {
if ([UIWindow instancesRespondToSelector:@selector(safeAreaInsets)]) { if ([UIWindow instancesRespondToSelector:@selector(safeAreaInsets)]) {
return [self tz_safeAreaInsets].top ?: 20; return [self tz_safeAreaInsets].top ?: 20;
......
...@@ -361,6 +361,11 @@ ...@@ -361,6 +361,11 @@
NSInteger left = 30; NSInteger left = 30;
NSInteger widthHeight = self.view.tz_width - 2 * left; NSInteger widthHeight = self.view.tz_width - 2 * left;
NSInteger top = (self.view.tz_height - widthHeight) / 2; NSInteger top = (self.view.tz_height - widthHeight) / 2;
if ([TZCommonTools tz_isLandscape]) {
top = 30;
widthHeight = self.view.tz_height - 2 * left;
left = (self.view.tz_width - widthHeight) / 2;
}
imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight); imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
imagePickerVc.scaleAspectFillCrop = YES; imagePickerVc.scaleAspectFillCrop = YES;
// 设置横屏下的裁剪尺寸 // 设置横屏下的裁剪尺寸
......
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