首页 > 其他 > 详细

获取视图尺寸大小方法

时间:2014-04-20 09:37:01      阅读:1066      评论:0      收藏:0      [点我收藏+]

iOS获取屏幕分辨率

获取屏幕分辨率可以两步走

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    真实的设备分辨率

bubuko.com,布布扣
//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;
View Code

 

 

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

获取视图尺寸大小方法,布布扣,bubuko.com

获取视图尺寸大小方法

原文:http://www.cnblogs.com/hl666/p/3675566.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!