如何使用代码获取屏幕大小? [英] How to get screen size using code?
本文介绍了如何使用代码获取屏幕大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想得到iphone屏幕尺寸给出计算,但我没有找到任何文档如何得到它。
I would like to get the iphone screen size to give calculation, but I did not found any documentation how to get it. Would you please figure it out for me?
感谢
推荐答案
您可以在UIScreen的实例上使用 bounds
属性:
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;
大多数人会想要主屏幕;如果您有一台设备连接到电视,您可以改为在UIScreen上迭代并获取每个的边界。
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类文档。
这篇关于如何使用代码获取屏幕大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文