1
print(UIScreen.main.currentMode?.size) // 750 * 1624
print(UIScreen.main.bounds.size) // 375 * 812
print(UIScreen.main.nativeBounds) // 828 * 1792

I use launch storyboard.

ZhaoWei
  • 101
  • 1
  • 8

1 Answers1

1

From Apple Documentation

UIScreen.main.nativeBounds: The bounding rectangle of the physical screen, measured in pixels.

UIScreen.main.bounds: The bounding rectangle of the screen, measured in points.

UIScreen.main.bounds.size The screen size, measured in pixels.

Pixels vs Points from here

A pixel on iOS is the full resolution of the device, which means if I have an image that is 100x100 pixels in length, then the phone will render it 100x100 pixels on a standard non-retina device. However, because newer iPhones have a quadrupled pixel density, that same image will render at 100x100 pixels, but look half that size. The iOS engineers solved this a long time ago (way back in OS X with Quartz) when they introduced Core Graphics' point system. A point is a standard length equivalent to 1x1 pixels on a non-retina device, and 2x2 pixels on a retina device. That way, your 100x100 image will render twice the size on a retina device and basically normalize what the user sees.

It also provides a standard system of measurement on iOS devices because no matter how the pixel density changes, there have always been 320x480 points on an iPhone screen and 768x1024 points on an iPad screen.*

Aryan Sharma
  • 625
  • 2
  • 9
  • 24
  • Could you explain what you mean by "there have always been 320x480 points on an iPhone screen"? This doesn't seem to line up well with the info on top row of this page, for example: https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions – Seemingly Unimaginative Oct 23 '20 at 18:27