Search code examples
iphoneobjective-cuiimageretina-display

UIImage get retina size


I want to know how can a retrieve a UIImage size, depending on the type of display that I'm using.

UIImage * refimg = [UIImage imageNamed:@"people-there.png"];
NSLog(@"SIZE: %f",refimg.size.height);

The output is

SIZE: 62.000000

... on both iPhone 3gs and iPhone 4g. I have the image "[email protected]" in the same directory as "people-there.png"

How can I get "SIZE: 124.000" on retina display?

Thanks in advance,

Lucas.


Solution

  • UIImage has a scale property that you can use.

    UIImage * refimg = [UIImage imageNamed:@"people-there.png"];
    NSLog(@"SIZE: %f", refimg.scale * refimg.size.height);