How to get device width and height?

后端 未结 12 1174
离开以前
离开以前 2020-12-23 14:13

In Objective-C we can get device width and height by using following code :

CGRect sizeRect = [UIScreen mainScreen].applicationFrame
float width = sizeRect.         


        
12条回答
  •  情书的邮戳
    2020-12-23 15:00

    While @Adam Smaka's answer was close, in Swift 3 it is the following:

    let screenBounds = UIScreen.main.bounds
    let width = screenBounds.width
    let height = screenBounds.height
    

提交回复
热议问题