-1

可能重复:
如何为 iPhone 5 屏幕分辨率开发或迁移应用程序?

我有两组图像。一组图像到 iphone 4 背景图像和另一组图像到 iphone 5。如何使用这两个图像集创建我想要与两种屏幕尺寸兼容的 iphone 应用程序?我想检查 iphone 版本并使用一些编码应用图像吗?希望你能帮忙。谢谢你的帮助。

4

2 回答 2

0

我正在使用一个名为UIDevice. 你可以在这里找到源代码:https ://github.com/erica/uidevice-extension

我设置了一个简洁的小方法,根据屏幕尺寸布局视图。例子:

- (void)setupGUI
{  
    UIImage *backgroundImage;
    if ([[UIDevice currentDevice] platformType] == UIDevice5iPhone)
    {
        //4 inch screen
         backgroundImage = [[UIImage alloc] initWithCGImage:[UIImage imageNamed:@"main_background-568h@2x"].CGImage scale:2.0 orientation:UIImageOrientationUp];
    }
    else
    {
        //3.5 inch screen

        backgroundImage = [[UIImage imageNamed:@"main_background"] retain];
    }
    self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
    [backgroundImage release];
}
于 2012-11-17T14:13:01.997 回答
0

对于飞溅,您可以使用后缀-568h@2x

对于 UIImage,您可以使用:

[UIImage imageNamed:@"tryImage"]

你可以有tryImage.png,tryImage@2x.pngtryImage-568h@2x.png,但它似乎没有像我们想要的那样工作。

你也可以使用这样的技巧:https ://gist.github.com/3782351

于 2012-11-17T14:15:20.553 回答