iosswiftscreenscaleuiscreen

Why do UIScreen dimensions differ on iOS device and simulator?


In troubleshooting an app I'm developing, I discovered that the UIScreen.main.bounds.width differs between my iPhone 8 Plus real device vs the simulator. To narrow it down, I created a new Swift app from the iOS App template in Xcode 13.4.1 targetting iOS 15.5 and added one line of code in viewDidLoad():

print("\(UIScreen.main.bounds.width)x\(UIScreen.main.bounds.height)")

Running on the simulator I get the expected dimensions:

414.0x736.0

but on my device I get:

375.0x667.0

I can't figure out why the difference. Past answers on this topic talk about Launch Screen images and whatnot, but my understanding is that all went away with the Launch Storyboard which this default template is using.

BTW, deleting the Launch Storyboard from the project results in dimensions of 320x480 which is expected as the app drops back to "scaled mode". So I don't think that's a factor here.

Definitely an iPhone 8 plus:

Settings|General|About


Solution

  • Settings | Display & Brightness | Display Zoom was on. Turning it off fixed my issue.