如何在iOS上使用代码获取屏幕尺寸? [英] How to get screen size using code on iOS?
本文介绍了如何在iOS上使用代码获取屏幕尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取iPhone屏幕尺寸以进行计算?
How to get the iPhone screen size to give calculation?
推荐答案
您可以使用边界实例上的
属性:
You can use the bounds
property on an instance of UIScreen:
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;
大多数人都想要主屏幕;如果您有连接到电视的设备,则可能要遍历UIScreens并获取每个设备的界限。
Most people will want the main screen; if you have a device attached to a TV, you may instead want to iterate over UIScreens and get the bounds for each.
更多信息,请参见 UIScreen类文档。
这篇关于如何在iOS上使用代码获取屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文