iPhone OS 4.0的@ 2x图像 [英] @2x images for iPhone OS 4.0

查看:51
本文介绍了iPhone OS 4.0的@ 2x图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有尺寸为560 * 66的按钮图像,我可以放置iPhone 4.0设备上的按钮图像吗?我如何使用@ 2x给出按钮的长宽比.

解决方案

如果您要为iPhone和iPad制作通用应用,则需要采用这样的命名方案

  MyIcon.png//ipadMyIcon〜iphone.png//低分辨率iPhoneMyIcon@2x~iphone.png//高分辨率iPhone 

您不需要在ipad和iphone图片之间具有逐像素相关性,但是低分辨率和高分辨率图片必须精确地为1:2,即.如果低分辨率为50x50,那么高分辨率应为100x100.

4.0中存在一个错误,您必须在@iphone之后放置@ 2x ,该问题在4.1中已修复",因此您必须再次将它放在前面.这意味着,如果您希望通用应用程序同时支持4.0和4.1+,则同时需要-一个MyImage@2x~iphone.png和一个MyImage~iphone@2x.png由于这个原因,我们最终不支持4.0.

当您想用代码调用图标时,只需

  UIImage * MyImage = [UIImage imageNamed:@"MyIcon.png"]; 

它将根据您的设备确定要使用的图片.

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.

解决方案

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.

这篇关于iPhone OS 4.0的@ 2x图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆