开发者

Obj-C, Using [button setImage:image]; how do I maximize the quality?

I'm about to resize some images, for use with buttons.

However, I think setImage will resize the images to the right size for the buttons.

My buttons are 72 x 72, according to IB.

I think I'm going to need to produce some retina size buttons too ?

What size should I create my images so that the iphone doesn't开发者_JS百科 need to resize my images ?


Create 72x72px images for the normal iPhone screens and double the size for retina displays. So that would be 144x144px images for retina displays.

If your include the images in the resources folder of your project make sure to append @2x.png to the name of the retina version of your image. This way the iPhone will use this image automatically when the button is displayed on an iPhone with retina display.

For example name the 72x72px image: button.png And name the 144x144px image button@2x.png.

Then select button.png in InterfaceBuilder or use [button setImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal] to set the image in code. The iPhone will automatically load the retina version when needed.


I think it would be better to create two images, One for iPhone 3 , iPad and other for iPhone 4. As per my information iPhone provides some naming convention for images in iPhone 3 and 4 device. Check out following.

http://useyourloaf.com/blog/2010/6/29/updating-for-the-iphone-4-retinal-display.html

if button is of 72X72 then for iphone 4 make image of 144X144

Hope it helps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜