国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ios8中的UIScreen

2019-11-14 19:38:54
字體:
來源:轉載
供稿:網友
java代碼 復制代碼 收藏代碼
  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)")

 在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)

 

在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)

 

結論:

1、在ios7中UIScreen.mainScreen().bounds是固定不變的值,在ios8中他的值是隨橫豎屏改變的!

為了在ios8中得到原來的效果可以:

Java代碼 復制代碼 收藏代碼
  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、

在ios8中增加了2個屬性:

nativeBounds :  屏幕像素,不隨橫豎平改變的!

nativeScale   :1(non retina)/2(retina)/3(retina hd)

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/index.html

ios8輸出:

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、從UIScreen.mainScreen().applicationFrame輸出值看出,ios8默認橫屏statusbar是隱藏掉了。你可以根據plist中

View controller-based status bar appearance的值的不同來用       

 

Java代碼 復制代碼 收藏代碼
  1. UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)  
UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)

 

Java代碼 復制代碼 收藏代碼
  1. override func prefersstatusBarHidden() -> Bool {  
  2.       return false  
  3.   
  4.   }  
  override func prefersStatusBarHidden() -> Bool {        return false     }

顯示橫屏statusbar


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵台县| 格尔木市| 乌拉特后旗| 肥东县| 无为县| 阿拉善盟| 乌鲁木齐市| 锦州市| 弋阳县| 昌乐县| 乌苏市| 隆德县| 白山市| 浑源县| 万荣县| 昔阳县| 开鲁县| 越西县| 莱芜市| 手机| 盐城市| 晴隆县| 七台河市| 易门县| 贵德县| 馆陶县| 绥中县| 上杭县| 大石桥市| 西乌珠穆沁旗| 永福县| 永仁县| 丹江口市| 温州市| 平山县| 西昌市| 台南县| 吴江市| 德惠市| 西乌珠穆沁旗| 惠来县|