UIScreen and ios8UIScreen in ios8
Java code
Let orientation: UIInterfaceOrientation = UIApplication. sharedApplication (). statusBarOrientation
Println ("Currently landscape:" + (orientation = UIInterfaceOrientation. LandscapeLeft | orientation = UIInterfaceOrientation. LandscapeRight )? "YES": "NO "))
Println ("UIScreen. mainScreen (). bounds: \ (UIScreen. mainScreen (). bounds )")
Println ("UIScreen. mainScreen (). applicationFrame: \ (UIScreen. mainScreen (). applicationFrame )")
let orientation: UIInterfaceOrientation = UIApplication.sharedApplication().statusBarOrientation println("Currently landscape: " + ((orientation == UIInterfaceOrientation.LandscapeLeft||orientation == UIInterfaceOrientation.LandscapeRight) ?"YES":"NO")) println("UIScreen.mainScreen().bounds: \(UIScreen.mainScreen().bounds)") println("UIScreen.mainScreen().applicationFrame: \(UIScreen.mainScreen().applicationFrame)")
Output in ios7:
Currently landscape: NO
UIScreen. mainScreen (). bounds: (0.0, 0.0, 320.0, 568.0)
UIScreen. mainScreen (). applicationFrame: (0.0, 20.0, 320.0, 548.0)
Currently landscape: YES
UIScreen. mainScreen (). bounds: (0.0, 0.0, 320.0, 568.0)
UIScreen. mainScreen (). applicationFrame: (20.0, 0.0, 300.0, 568.0)
Output in ios8:
Currently landscape: NO
UIScreen. mainScreen (). bounds: (0.0, 0.0, 320.0, 568.0)
UIScreen. mainScreen (). applicationFrame: (0.0, 20.0, 320.0, 548.0)
Currently landscape: YES
UIScreen. mainScreen (). bounds: (0.0, 0.0, 568.0, 320.0)
UIScreen. mainScreen (). applicationFrame: (0.0, 0.0, 568.0, 320.0)
Conclusion:
1. In ios7, UIScreen. mainScreen (). bounds is a fixed value. In ios8. its value changes with the landscape and landscape!
In order to get the original effect in ios8:
Java code
+ (CGSize) screenSize {
CGSize screenSize = [UIScreen mainScreen]. bounds. size;
Return CGSizeMake (MIN (screenSize. width, screenSize. height), MAX (screenSize. width, screenSize. height ));
}
+ (CGSize)screenSize { CGSize screenSize = [UIScreen mainScreen].bounds.size; return CGSizeMake(MIN(screenSize.width, screenSize.height), MAX(screenSize.width, screenSize.height));}
2,
Two attributes are added to ios8:
NativeBounds: screen pixels, which do not change horizontally or vertically!
NativeScale: 1 (non retina)/2 (retina)/3 (retina hd)
Https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/index.html#//apple_ref/occ/instp/UIScreen/nativeBounds
Ios8 output:
Currently landscape: YES
UIScreen. mainScreen (). bounds: (0.0, 0.0, 568.0, 320.0)
UIScreen. mainScreen (). applicationFrame: (0.0, 20.0, 568.0, 300.0)
UIScreen. mainScreen (). nativeBounds: (0.0, 0.0, 640.0, 1136.0)
UIScreen. mainScreen (). nativeScale: 2.0
Currently landscape: NO
UIScreen. mainScreen (). bounds: (0.0, 0.0, 320.0, 568.0)
UIScreen. mainScreen (). applicationFrame: (0.0, 20.0, 320.0, 548.0)
UIScreen. mainScreen (). nativeBounds: (0.0, 0.0, 640.0, 1136.0)
UIScreen. mainScreen (). nativeScale: 2.0
3. The output value of UIScreen. mainScreen (). applicationFrame indicates that the statusbar of ios8 is hidden by default. You can
View controller-based status bar appearance values are different
Java code
UIApplication. sharedApplication (). setStatusBarHidden (false, withAnimation: UIStatusBarAnimation. None)
UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)
Or
Java code
Override func prefersStatusBarHidden ()-> Bool {
Return false
}
override func prefersStatusBarHidden() -> Bool { return false }
Display landscape statusbar