iOS 如何获取屏幕大小
Posted 张玉宝
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS 如何获取屏幕大小相关的知识,希望对你有一定的参考价值。
1 2 UIScreen *currentScreen = [UIScreen mainScreen]; 3 4 NSLog(@"applicationFrame.size.height = %f",currentScreen.applicationFrame.size.height); 5 6 NSLog(@"applicationFrame.size.width = %f",currentScreen.applicationFrame.size.width); 7 8 NSLog(@"applicationFrame.origin.x = %f",currentScreen.applicationFrame.origin.x); 9 10 NSLog(@"applicationFrame.origin.y = %f",currentScreen.applicationFrame.origin.y); 11 12 NSLog(@"bounds.x = %f",currentScreen.bounds.origin.x); 13 14 NSLog(@"bounds.y = %f",currentScreen.bounds.origin.y); 15 16 NSLog(@"bounds.height = %f",currentScreen.bounds.size.height); 17 18 NSLog(@"bounds.width = %f",currentScreen.bounds.size.width); 19 20 NSLog(@"brightness = %f",currentScreen.brightness);
更新:
ios 9 之后:使用 [UIScreen mainScreen].bounds代替 [UIScreen mainScreen].applicationFrame
以上是关于iOS 如何获取屏幕大小的主要内容,如果未能解决你的问题,请参考以下文章