Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?

后端 未结 18 1070
北恋
北恋 2020-11-22 16:55

I ran the following code in both iOS 7 and iOS 8:

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landsca         


        
18条回答
  •  时光说笑
    2020-11-22 17:44

    I needed a quick helper function that kept the same behavior as iOS7 under iOS8 - this allowed me to swap out my [[UIScreen mainScreen] bounds] calls and not touch other code...

    + (CGRect)iOS7StyleScreenBounds {
        CGRect bounds = [UIScreen mainScreen].bounds;
        if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
            bounds.size = CGSizeMake(bounds.size.height, bounds.size.width);
        }
            return bounds;
    }
    

提交回复
热议问题