0

我应该为 iphone 6 和 iphone 6+ 应用程序使用什么大小的 bg 图像。同样的扩展名应该是什么。当我阅读一些帖子时,我知道我们应该为 iphone 6 使用@2x 图像。但 4s 设备也使用@2x 图像;那么您将如何区分 4s 设备和 iphone 6 使用的图像。

4

2 回答 2

0

我使用以下代码来确定正在运行的设备(它有点快速和肮脏,但它可以解决问题)

if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ){

    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    if( screenHeight < screenWidth ){
        screenHeight = screenWidth;
    }

    if( screenHeight > 480 && screenHeight < 667 ){
        DLog(@"iPhone 5/5s");
    } else if ( screenHeight > 480 && screenHeight < 736 ){
        DLog(@"iPhone 6");
    } else if ( screenHeight > 480 ){
        DLog(@"iPhone 6 Plus");
    } else {
        DLog(@"iPhone 4/4s");
    }
}

尺寸是: 在此处输入图像描述

于 2014-10-16T09:29:10.990 回答
0

是的。它使用从 iPhone4s 到 iphone 6 相同的 imageName@2x.png。但是您可以从屏幕边界获取 nativeBounds 和nativeScale

此外,您可以使用这个:

例如:

例如: 在此处输入图像描述

如果您在 UIImageView 中显示照片,您可以创建最大尺寸并让它缩小到 iPhone 4s(使用 UIViewContentModeScaleAspectFill)或保持原样(使用 UIViewContentModeCenter)。

对于您的 Bg 问题:您可以将自动布局约束与 ImageView 一起使用。另外,你可以使用这个

于 2014-10-15T07:26:07.813 回答