【发布时间】:2014-06-20 06:36:11
【问题描述】:
我想知道我想在 iOS 应用上用作背景的图像应该是什么尺寸。我的申请将仅是纵向的。 问题是我的图像不是那种简单的图像
相反,我有一张我不想从导航栏和选项卡栏看到的图像。类似的东西:
我的问题是:这个图像的正确尺寸是多少才能在 iphone、iphone4 和 iphone5 上看起来不错,以及 xCode 将如何知道必须使用哪个图像?我必须使用哪些名称。如果我使用 背景.png 背景@2x.png 那么带有视网膜屏幕的iphone4和iphone5将使用background@2x.png 但是iphone5的高度更大。谁能帮我理解一下?
更新
解决方案:我为 iphone5 使用了 320x455 的尺寸用于名称为 Default-568h.png 的图像和 640x910 用于名称为 Default-568h@2x.png 的图像。对于所有其他 iphone 设备,名称为 Default.png 的图像为 320x367,图像 Default@2x.png 为 640x734。然后我在 viewDidLoad 上使用了这段代码:
#define IS_iPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)
if (IS_iPhone5)
{
UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default-568h.png"]];
[self.view addSubview:backgroundImage];
[self.view sendSubviewToBack:backgroundImage];
}
else
{
UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
[self.view addSubview:backgroundImage];
[self.view sendSubviewToBack:backgroundImage];
}
【问题讨论】: