iPhone Image Resolution
I am creating an app that has images in a picker view, but I have noticed that these images appear pixelated. Cu开发者_如何学运维rrently, I have the resolution set at 72 pixels/inch. I have increased it to 300 pixels/inch, but have not noticed a change. Has anyone run into the issue?
If you are creating these images in Photoshop, changing the DPI won't change the image file. A 4x4 image will have 16 pixels. When you change the DPI, it simply changes how large those pixels are on your display. In the case of the retina display, You need to create an image that is double the size (e.g. 8x8).
YOu need to provide the same file as a "@2x" file with double the size. For example, if you have:
myImage.png #32x32
Then you also need:
myImage@2x.png #64x64
When calling the resource, you can use the same way and ignore the @2x
part of the filename. IOS will do the right thing. On high density devices, it will choose the bigger file, otherwise it will choose the smaller one.
[UIImage imageNamed:@"myImage.png"]
You dont need the png, but it works with or without it. This code works on all OS's. If it is a retina display, it will use the big image, otherwise not try it.
精彩评论