@2x images for iPhone OS 4.0

一世执手 提交于 2019-12-08 02:43:48

问题


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.


回答1:


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.




回答2:


  • 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.



回答3:


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.




回答4:


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..



来源:https://stackoverflow.com/questions/4886019/2x-images-for-iphone-os-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!