什么名字图像iPhone 5屏幕尺寸? [英] What to name images for iPhone 5 screen size?

查看:70
本文介绍了什么名字图像iPhone 5屏幕尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

4英寸视网膜显示器的图像的新命名惯例是什么?

What is the new naming convention for images for the 4-inch retina display?

对于名为 background.png的图像您将 @ 2x 添加到名称( background@2x.png ),以告诉iOS将其用于视网膜

For an image named background.png you add @2x to the name (background@2x.png) to tell iOS to use that one for devices with the retina display.

推荐答案

您可以使用我的 #define 帮助您处理这些图片:

You can use my #defines to help you with these images:

#define isPhone568 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568)
#define iPhone568ImageNamed(image) (isPhone568 ? [NSString stringWithFormat:@"%@-568h.%@", [image stringByDeletingPathExtension], [image pathExtension]] : image)
#define iPhone568Image(image) ([UIImage imageNamed:iPhone568ImageNamed(image)])

只需给你的图片-568h@2x.png符号,并使用 iPhone568ImageNamed 以获取标准名称或iPhone 5 /新iPod的名称。

Just give your images the -568h@2x.png notation, and use iPhone568ImageNamed to get a name for standard name or iPhone 5/new iPod.

评论中的使用示例:

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:iPhone568ImageNamed(@"mainscreen.png")]];

这篇关于什么名字图像iPhone 5屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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