The UIScreen in iOS8

Source: Internet
Author: User

Java code
    1. Let orientation:uiinterfaceorientation = Uiapplication.sharedapplication (). statusbarorientation
    2. println ("Currently Landscape:" + ((orientation = = Uiinterfaceorientation.landscapeleft| | Orientation = = uiinterfaceorientation.landscaperight)? " YES":"NO"))
    3. println ("Uiscreen.mainscreen (). Bounds: \ (Uiscreen.mainscreen (). Bounds)")
    4. 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 his value is changed with the screen!

In order to get the original effect in iOS8, you can:

Java code
    1. + (Cgsize) screensize {
    2. Cgsize screensize = [UIScreen mainscreen].bounds.size;
    3. return Cgsizemake (MIN (Screensize.width, Screensize.height), MAX (Screensize.width, screensize.height));
    4. }
+ (Cgsize) screensize {    cgsize screensize = [UIScreen mainscreen].bounds.size;    Return Cgsizemake (MIN (Screensize.width, Screensize.height), MAX (Screensize.width, Screensize.height));}

2.

2 Properties added in iOS8:

Nativebounds: screen pixels, do not change with the horizontal!

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, from Uiscreen.mainscreen (). Applicationframe output value, iOS8 the default horizontal screen StatusBar is hidden away. You can follow the plist

View controller-based status bar appearance for different values

Java code
    1. Uiapplication.sharedapplication (). Setstatusbarhidden (false, WithAnimation:UIStatusBarAnimation.None)
Uiapplication.sharedapplication (). Setstatusbarhidden (False, WithAnimation:UIStatusBarAnimation.None)

Or

Java code
    1. Override Func Prefersstatusbarhidden (), Bool {
    2. return false
    3. }
  Override Func Prefersstatusbarhidden (), Bool {        return False     }

Display horizontal Screen StatusBar

UIScreen in iOS8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.