Get Device Height And Width Wift

[Solved] Get Device Height And Width Wift | Swift - Code Explorer | yomemimo.com
Question : get device height and width wift

Answered by : ahsan-lwa8tagab3go

//In Swift 5.0
let screenSize: CGRect = UIScreen.main.bounds
//Swift 4.0
// Screen width.
public var screenWidth: CGFloat { return UIScreen.main.bounds.width
}
// Screen height.
public var screenHeight: CGFloat { return UIScreen.main.bounds.height
}
//In Swift 3.0
let screenSize = UIScreen.main.bounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
//In older swift:
//Do something like this:
let screenSize: CGRect = UIScreen.mainScreen().bounds
//then you can access the width and height like this:
let screenWidth = screenSize.width
let screenHeight = screenSize.height

Source : https://stackoverflow.com/questions/24110762/swift-determine-ios-screen-size | Last Update : Sun, 09 Jan 22

Answers related to get device height and width wift

Code Explorer Popular Question For Swift