Determine Main Screen Height and Width

In this short Swift code example, you will learn how to determine main screen bounds as well as screen height and width in Swift.

  • Get main screen bounds
  • Get screen width
  • Get screen height
// Get main screen bounds
let screenSize: CGRect = UIScreen.main.bounds

let screenWidth = screenSize.width
let screenHeight = screenSize.height

print("Screen width = \(screenWidth), screen height = \(screenHeight)")

For more Swift code examples and tutorials, please check the Swift Code Examples page on this website.


Leave a Reply

Your email address will not be published. Required fields are marked *

Free Video Lessons

Enter your email and stay on top of things,

Subscribe!