Fix landscape screenshot issues in iOS 8

This commit is contained in:
Andreas Linde 2015-02-18 15:08:15 +01:00
parent bc475061f2
commit b9f149b33e
2 changed files with 11 additions and 6 deletions

View File

@ -742,7 +742,10 @@ UIImage *bit_screenshot(void) {
BOOL isLandscapeRight = [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight;
BOOL isUpsideDown = [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown;
if (isLandscapeLeft ||isLandscapeRight) {
BOOL needsRotation = NO;
if ((isLandscapeLeft ||isLandscapeRight) && imageSize.height > imageSize.width) {
needsRotation = YES;
CGFloat temp = imageSize.width;
imageSize.width = imageSize.height;
imageSize.height = temp;
@ -771,10 +774,12 @@ UIImage *bit_screenshot(void) {
-[window bounds].size.width * [[window layer] anchorPoint].x,
-[window bounds].size.height * [[window layer] anchorPoint].y);
if (needsRotation) {
if (isLandscapeLeft) {
CGContextConcatCTM(context, CGAffineTransformRotate(CGAffineTransformMakeTranslation( imageSize.width, 0), M_PI / 2.0));
} else if (isLandscapeRight) {
CGContextConcatCTM(context, CGAffineTransformRotate(CGAffineTransformMakeTranslation( 0, imageSize.height), 3 * M_PI / 2.0));
}
} else if (isUpsideDown) {
CGContextConcatCTM(context, CGAffineTransformRotate(CGAffineTransformMakeTranslation( imageSize.width, imageSize.height), M_PI));
}

View File

@ -153,7 +153,7 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
- (void)fitImageViewFrame {
CGSize size = [UIScreen mainScreen].bounds.size;
if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)){
if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) && size.height > size.width){
size = CGSizeMake(size.height, size.width);
}