ios8中的UIScreen
来源:互联网 发布:什么是好的域名 编辑:程序博客网 时间:2024/04/26 18:10
- 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中得到原来的效果可以:
- + (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#//apple_ref/occ/instp/UIScreen/nativeBounds
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的值的不同来用
- UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.None)
或
- override func prefersStatusBarHidden() -> Bool {
- return false
- }
显示横屏statusbar
- ios8中的UIScreen
- ios8中的UIScreen
- ios8中的UIScreen
- iOS8中的[UIScreen mainScreen].bounds 和 [UIScreen mainScreen].applicationFrame
- 『IOS』ios8中的UIScreen
- iOS8中的UIScreen、UIWindow、键盘尺寸、状态栏尺寸的改动
- iOS8中的[UIScreen mainScreen].bounds 和 [UIScreen mainScreen].applicationFrame(下)
- [ UIScreen mainScreen ].bounds;在IOS7和IOS8的区别
- ios8和之前系统[UIScreen mainScreen].bounds的不一样
- UIScreen
- UIScreen
- UIScreen
- UIScreen 中的applicationFrame和bounds的区别
- ios7、ios8中的UITableViewCellEditingStyle
- iOS8中的playground新功能
- iOS8 中的 Size Class
- iOS8中的playground新功能
- iOS8中的Extension扩展
- 函数
- 顺时针打印矩阵
- vim琐碎知识点
- 黑马程序员——java学习日记八
- CoreData 基础
- ios8中的UIScreen
- 小小菜之Cocos2d-x游戏开发旅程——Lua打包apk
- Windows API教程文件系统
- inode的理解
- Detecting iPhone 6/6+ screen sizes in point values
- Hadoop、Spark、HBase与Redis的适用性讨论
- UVa10391-- Compound Words(字符串hash)
- c/c++ for matlab (mexFunction)
- Java内部类总结