How to get the device's scale factor?

The device's scale factor is a property of UIScreen. You can obtain it by:

[UIScreen mainScreen].scale;

Documentation here.


Swift 3+ version:

UIScreen.main.scale

Swift5+ / macOS Big Sur:

let backingScaleFactor = NSScreen.main?.backingScaleFactor