获取屏幕分辨率可以两步走
1、得到当前屏幕的尺寸:
CGRect rect_screen = [[UIScreenmainScreen]bounds];
CGSize size_screen = rect_screen.size;
2、获得scale:
CGFloat scale_screen = [UIScreen mainScreen].scale;
此时屏幕尺寸的宽高与scale的乘积就是相应的分辨率值。
[[UIScreen mainScreen] bounds] 屏幕大小
self.view.frame.size.width 宽度
self.view.frame.size.hight 高度
[UIScreen mainScreen].currentMode.size 真实的设备分辨率
//1 Available in iOS 4.0 and later UIScreen *MainScreen = [UIScreen mainScreen]; CGSize Size = [MainScreen bounds].size; CGFloat scale = [MainScreen scale]; CGFloat screenWidth = Size.width * scale; CGFloat screenHeight = Size.height * scale; //2 Available in iOS 3.2 and later UIScreen *MainScreen = [UIScreen mainScreen]; UIScreenMode *ScreenMode = [MainScreen currentMode]; CGSize Size = [ScreenMode size]; CGFloat screenWidth = Size.width; CGFloat screenHeight = Size.height;
App尺寸,去掉状态栏
1 |
CGRect r = [ UIScreen mainScreen ].applicationFrame; //r=0,20,320,460 |
屏幕尺寸
CGRect rx = [ UIScreen mainScreen ].bounds; //r=0,0,320,480
CGRect rect = [[UIApplication sharedApplication] statusBarFrame];
iphone中获取屏幕分辨率的方法
1
2
3
4 |
CGRect rect = [[UIScreen mainScreen] bounds]; CGSize size = rect.size; CGFloat width = size.width; CGFloat height = size.height; |
其它参考 http://www.gowhich.com/blog/486
iOS 设备的屏幕尺寸、分辨率及其屏幕边长比例详细情况是怎样的?
http://www.zhihu.com/question/20583941
原文:http://www.cnblogs.com/hl666/p/3675566.html