如何以编程方式获取iphone屏幕尺寸? [英] how to get iphone screen size programatically?
本文介绍了如何以编程方式获取iphone屏幕尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何使用代码获取屏幕尺寸?
NSLog(@"Top Left View : Width %f height%f",self.topLeftView.frame.size.width,self.topLeftView.frame.size.height);
我已从对象库中拖出View并将其放在xib文件中。
但是,如果我想获得屏幕大小来检查它的iphone 4,iPhone 3或iphone 5或任何iOS设备。
I have dragged the "View" from object library and put it on xib file.
But what if i want to get the screen size to check whether its iphone 4,iPhone 3 or iphone 5 or any iOS Device.
这样我就可以相应地安排其他观点
So that i can arrange other views accordingly
推荐答案
你可以使用:
CGsize screenSize = [[[UIScreen mainScreen] bounds] size];
CGFloat widthOfScreen = screenSize.width;
CGFloat heightOfScreen = screenSize.height;
这篇关于如何以编程方式获取iphone屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文