@2x images for iPhone OS 4.0
i have button image of size 560*66 can i put this button image iPhone 4.0 device?and al开发者_如何学编程so how will i give aspect ratio this button by using @2x.
If you are making a universal app, for both iphone and ipad, then you need to have a naming scheme like this
MyIcon.png //ipad MyIcon~iphone.png //low res iphone MyIcon@2x~iphone.png //high res iphone
You don't need to have a pixel wise correlation between the ipad and the iphone pictures, but the low res and high res pictures need to be exactly 1:2, ie. if the low res is 50x50 then the high res should be 100x100.
There is a bug in 4.0 where you have to put the @2x after the ~iphone, which is "fixed" in 4.1 so you have to put it ahead of it again. This means, if you want your universal app to support both 4.0 and 4.1+ then you need both - one MyImage@2x~iphone.png and one MyImage~iphone@2x.png We ended up not supporting 4.0 for this reason.
When you want to call your icon in the code you just do
UIImage * MyImage = [UIImage imageNamed: @"MyIcon.png"];
And it will figure out which picture to use depending on your device.
- To the first question: Yes.
- To the second question: You don't "give" aspect ratio using the "@2x" suffix. You need to clarify your question.
You need to have a standard (1x with 280x33 px) version of you image. You will call it for example image.png, then you have also your image@2x.png (560x66 px), in interface builder you will use the standard version of your image in your button (Both images needs to be included in your xCode project).
At run time, the system will automatically choose the good resource depending on your iPhone (retina or not).
Think in point and not in pixel. The iPhone is 320 points width (With double density images for the retina) so your image will always be displayed with 280 points width.
you have to add @2x to youre iPhone 4 image
So if you have a 30x30 image named myButton.png, make a 60x60 version and name it myButton@2x.png..
精彩评论