本文介绍了什么名字图像iPhone 5屏幕尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
4英寸视网膜显示器的图像的新命名惯例是什么?
What is the new naming convention for images for the 4-inch retina display?
对于名为 background.png的图像
您将 @ 2x 添加到名称( [email protected]
),以告诉iOS将其用于视网膜
For an image named background.png
you add @2x to the name ([email protected]
) to tell iOS to use that one for devices with the retina display.
推荐答案
您可以使用我的 #define
帮助您处理这些图片:
You can use my #define
s 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)])
只需给你的图片[email protected]符号,并使用 iPhone568ImageNamed
以获取标准名称或iPhone 5 /新iPod的名称。
Just give your images the [email protected] 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屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!