【问题标题】:What are the correct sizes for a background image for an iOS appiOS应用程序的背景图像的正确尺寸是多少
【发布时间】: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,图像 Def​​ault@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];

}

【问题讨论】:

    标签: ios iphone xcode image


    【解决方案1】:
    #define IS_iPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)
    
     if (IS_iPhone5)
        {
            self.backGroundImageView.image = [UIImage imageNamed:@"Default-568h.png"];
            self.backGroundImageView.frame = CGRectMake(0, 0, 320, 568);
        }
        else
        {
            self.backGroundImageView.image = [UIImage imageNamed:@"Default.png"];
            self.backGroundImageView.frame = CGRectMake(0, 0, 320, 480);
        }
    

    【讨论】:

    • 感谢您的快速回复。我把这段代码放在了vewDidLoad上。我的项目中有正确名称的图像,但屏幕上没有显示任何内容。我错过了什么?
    • @nana ..在实际视图中添加了 backGroundImageView 对象。喜欢 [self.view addSubView: backGroundImageView];或者您已经从情节提要中添加它
    • @nana ..很高兴知道...如果您发现它有用或正确引导,您可以在我的评论中选择喜欢。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-26
    • 2012-04-27
    • 2014-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多