How to get device width and height?

后端 未结 12 1172
离开以前
离开以前 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 14:55

    Since you're looking for the device screen size the simplest way is:

    let screenSize = UIScreen.mainScreen().bounds.size
    let width = screenSize.width
    let height = screenSize.height
    

提交回复
热议问题