Reputation: 21
i have button image of size 560*66 can i put this button image iPhone 4.0 device?and also how will i give aspect ratio this button by using @2x.
Upvotes: 2
Views: 4821
Reputation: 984
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 [email protected] 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.
Upvotes: 6
Reputation: 1377
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 [email protected]..
Upvotes: 0
Reputation: 11774
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 [email protected] (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.
Upvotes: 1
Reputation: 185852
Upvotes: 1