Search code examples
objective-ciosuiimage

How to get the device's scale factor?


I've been using UIGraphicsBeginImageContextWithOptions() and I noticed that the last field in that method is a scalefactor. And the apple docs says, if I want to set it to 0.0, then it will use the default scale factor of the device's main screen. Is there a way to get that default scale factor via property or method?


Solution

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

    [UIScreen mainScreen].scale;
    

    Documentation here.