iOS 获取屏幕尺寸

在 iOS 开发中,可以使用 UIScreen 类获取设备屏幕的尺寸信息。UIScreen.main.bounds 属性返回一个 CGRect 结构体,该结构体包含屏幕的宽度、高度和原点坐标。

let screenWidth = UIScreen.main.bounds.width
let screenHeight = UIScreen.main.bounds.height

screenWidth 变量存储屏幕的宽度,screenHeight 变量存储屏幕的高度。

rtf 文件大小:2.11KB