37

I have an app that uses a service to get some icons.

With this service I can get any image of any size, so I've planned to get the 3 images (@1x, @2x and @3x) and store them on the BBDD, and then get the scale to use one of these three; or maybe get only the one according with the device scale.

But the thing is, how can I get the device scale (@1x, @2x and @3x) programmatically?

Both Obj-c and Swift are welcomed ;)

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
javiazo
  • 1,892
  • 4
  • 26
  • 41

1 Answers1

78

Use

[UIScreen mainScreen].scale;

this will give you the exact scale as per device.

In Swift 3

UIScreen.main.scale

Cheers.

Josh Brown
  • 52,385
  • 10
  • 54
  • 80
iphonic
  • 12,615
  • 7
  • 60
  • 107