Why the property Size of UIImage is half of the real picture size?

时间:2016-02-03 03:37:19

标签: ios uiimage size

I have a picture named pic of 268*381, I have defined

UIImage* tempImg = [UIImage imageNamed:@"pic"];

But when I print

NSStringFromCGSize(tempImg.size)

it shows {134, 190.5}

I can't understand the principle of this, and I would be very grateful the solver!

1 个答案:

答案 0 :(得分:0)

From the docs for UIImage size:

In iOS 4.0 and later, this value reflects the logical size of the image and is measured in points

Remember that pixels is equal to points times scale. Or points is pixels divided by scale.

Your 268x381 size is in pixels. The output of NSStringFromCGSize(tempImg.size) is in points. A result of {134, 190.5} means this is an image with a scale of 2. Most likely you have this image as pic@2x.png.