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 targeting 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.

Answered by Frameworks Engineer in 716583022

Do you have zoomed mode enabled on your iPhone? If you turn it off, you should get the same dimensions.

The 375.0x667.0 dimensions look like your physical devices is in zoom mode. Can you confirm that it isn't?

Accepted Answer

Do you have zoomed mode enabled on your iPhone? If you turn it off, you should get the same dimensions.

Why do UIScreen dimensions differ on iOS device and simulator?
 
 
Q