如何获得iOS设备屏幕的高度和宽度
问题描述:
考虑各种iOS设备和方向,获取当前屏幕分辨率的最简单方法是什么,包括高度和宽度?
Accounting for the various iOS devices and orientations, what is the simplest approach to getting the current screen resolution, including height and width?
答
UIScreen
是您的朋友。
UIScreen
is your friend here.
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;