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

后端 未结 18 1054
北恋
北恋 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:37

    iOS 8 or upper

    A solution for those who want to find out the screen size in points (3.5 inches screen has 320 × 480 points, 4.0 inches screen has 320 × 568 points, etc) would be

    - (CGSize)screenSizeInPoints
    {
        CGFloat width = [[UIScreen mainScreen] bounds].size.width;
        CGFloat height = [[UIScreen mainScreen] bounds].size.height;
    
        if (width > height) {
            return CGSizeMake(height, width);
        }
        else {
            return [[UIScreen mainScreen] bounds].size;
        }
    }
    

提交回复
热议问题