iPhone图像大小

时间:2015-04-17 01:47:01

标签: ios xcode resolution

我目前在我的项目中运行iPhone 6模拟器。 我知道使用不同的iPhone需要不同的分辨率设置。

如果我想为iPhone 4566+进行开发。在我的情况下,456+的大小应该是多少。我想我不需要改变6,因为我将它作为我的基础。 (如果可以,请将iPad添加到列表中)

如果有人可以指导iOS如何根据他们拥有的设备自动选择正确的图像分辨率。

任何问题只是评论!

1 个答案:

答案 0 :(得分:0)

我之前在Objective-C做过这个,所以请原谅我,如果它与Swift不同。

您必须为每个图片分辨率制作不同的.storyboard文件,然后在AppDelegate.m中添加一些代码,如:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIStoryboard *iPhone4storyBoard = [UIStoryboard storyboardWithName:@"storyboard4" bundle:[NSBundle mainBundle]];
    // Device is an iPhone 5 or 5S
    UIStoryboard *iPhone5storyBoard = [UIStoryboard storyboardWithName:@"storyboard5" bundle:[NSBundle mainBundle]];
    // And so on...

    if ([UIScreen mainScreen].bounds.size.height == 568.0) {
        self.window.rootViewController = [iPhone5storyBoard instantiateInitialViewController];
    } else if (/* test for other devices here */){
      self.window.rootViewController = [iPhone6storyBoard instantiateInitialViewController];
    }

    [self.window makeKeyAndVisible];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    return YES:
}

检查设备分辨率,并应用相关的故事板。

另外,建议调整图片大小:Use Prepo

Prepo会自动将应用程序图标和启动画面调整为所需的值。

相关问题