xcode 如何轻松制作 iPhone 启动图像?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9191046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:15:40  来源:igfitidea点击:

How can I make an iPhone launch image easily?

iphoneiosxcodesplash-screen

提问by nybon

According to Apple's guide line, an iPhone app's launch image/splash screen should be a prerendered static image that looks similar to the application's first screen.

根据 Apple 的指导方针,iPhone 应用程序的启动图像/启动画面应该是一个预渲染的静态图像,看起来类似于应用程序的第一个屏幕。

Here are some links to Apple's documentations about this:

以下是 Apple 相关文档的一些链接:

1) Launch images, iOS human interface guideline:

1)启动图片,iOS人机界面指南:

https://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW5

https://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW5

2) App Launch (Default) Images, iOS app programming guide:

2)App Launch(默认)图片,iOS应用编程指南:

https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html#//apple_ref/doc/uid/TP40007072-CH6-SW12

https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html#//apple_ref/doc/uid/TP40007072-CH6-SW12

I just wonder how can I create such launch image easily. In most cases, it seems the launch image should be a combination of empty status bar + navigation bar + empty table/view + tab bar, and each of them should be rendered with iOS's predefined color scheme.

我只是想知道如何轻松创建这样的启动图像。在大多数情况下,启动图像似乎应该是空状态栏 + 导航栏 + 空表/视图 + 标签栏的组合,并且每个都应该使用 iOS 预定义的配色方案进行渲染。

But I cannot find any documentation about how I should do this and cannot find any entry in Xcode which seems related with this. Is there any Apple's official tool to render the launch image easily? Or do all the app developers simply use some mockup iPhone controls + Photoshop to do this?

但是我找不到任何关于我应该如何执行此操作的文档,并且在 Xcode 中找不到任何似乎与此相关的条目。有没有苹果官方的工具可以轻松渲染启动图像?还是所有的应用程序开发人员都只是使用一些模型 iPhone 控件 + Photoshop 来做到这一点?

Any help is appreciated. Thanks.

任何帮助表示赞赏。谢谢。

采纳答案by Sebastian Wramba

It would not be much of a problem, do compose a static XIB file of your main screen (empty tab bar, empty navigation bar) or whatsoever. Just the backgrounds without any elements or labels placed on them.

这不是什么大问题,请为您的主屏幕(空标签栏、空导航栏)或其他任何内容编写一个静态 XIB 文件。只是背景,上面没有放置任何元素或标签。

You can launch this "empty" application in the iPhone Simulator which has a built-in screenshot function. With additional software like the iPhone Simulator Cropperyou can crop the image to the preferred size.

您可以在具有内置屏幕截图功能的 iPhone 模拟器中启动这个“空”应用程序。使用iPhone Simulator Cropper等附加软件,您可以将图像裁剪为首选尺寸。

That would be my approach to do this.

那将是我这样做的方法。

回答by Matthias Bauch

Since I find it cumbersome to remove content in the nib file I use a code approach.

由于我发现删除 nib 文件中的内容很麻烦,因此我使用了代码方法。

The code is different for each project. But you'll get the idea.

每个项目的代码都不同。但你会明白的。

// uncomment to take a screenshot for the launch image
//#define SCREENSHOTMODE 

- (void)viewDidLoad {
    [super viewDidLoad];
    /* regular stuff */
#ifdef SCREENSHOTMODE
        self.navigationItem.leftBarButtonItem = nil;
        self.navigationItem.rightBarButtonItem = nil;
        self.title = nil;
        [self deactivateContentForSubviewsInView:self.view];
#endif
}


#ifdef SCREENSHOTMODE
- (void)deactivateContentForSubviewsInView:(UIView *)contentView {
    for (UIView *aView in contentView.subviews) {
        if ([aView isKindOfClass:[UILabel class]]) {
            [(UILabel *)aView setText:nil];
        }
        else if ([aView isKindOfClass:[UITableView class]]) {
            [(UITableView *)aView setDataSource:nil];
        }
        else if ([aView isKindOfClass:[UIToolbar class]]) {
            [(UIToolbar *)aView setItems:nil];
        }
        else if ([aView isKindOfClass:[UIImageView class]]) {
            [(UIImageView *)aView setImage:nil];
        }
        else if ([aView isKindOfClass:[UIView class]]) {
            // i often put views in UIViews to group them
            [self deactivateContentForSubviewsInView:aView];
        }
    }
}
#endif

If you only have a handful of objects you can just remove the content of your UI-elements directly. Without loops.

如果您只有少数对象,则可以直接删除 UI 元素的内容。没有循环。

回答by nybon

It seems there is no such tool built in Xcode for this. I ended up with a method just like Sebastian Wramba said above with a little difference. I used Xcode 4.2 storyboarding for UI design of my app, here is my steps to do this in Xcode 4.2 storyboard:

Xcode 中似乎没有为此内置此类工具。我最终得到了一种方法,就像上面提到的 Sebastian Wramba 一样,但略有不同。我在我的应用程序的 UI 设计中使用了 Xcode 4.2 故事板,这是我在 Xcode 4.2 故事板中执行此操作的步骤:

  1. Drag an empty view controller from the "Object library" to the storyboard

  2. Add empty navigation bar/table view/tab bar/other components to the new scene above according to your initial screen layout

  3. Click the view controller in the storyboard, in the "Attributes Inspector" of the view controller, there is a checkbox called "Initial Scene: Is Initial View Controller". Check that.

  4. Launch the app in Xcode, your app's initial screen will be set to the one you just created. Take a screenshot and use that as the launch image.

  5. Set the initial scene back to your real initial scene by checking its "Initial Scene" checkbox.

  1. 将一个空的视图控制器从“对象库”拖到故事板

  2. 根据你的初始屏幕布局将空导航栏/表格视图/标签栏/其他组件添加到上面的新场景中

  3. 单击storyboard中的视图控制器,在视图控制器的“属性检查器”中,有一个名为“初始场景:是初始视图控制器”的复选框。检查那个。

  4. 在 Xcode 中启动应用程序,应用程序的初始屏幕将设置为您刚刚创建的屏幕。截取屏幕截图并将其用作启动图像。

  5. 通过选中“初始场景”复选框,将初始场景设置回您真正的初始场景。

I will still mark Sebastian Wramba's solution as the answer to my question since the general idea is the same, just create a dedicated UI in Xcode for it.

我仍然会将 Sebastian Wramba 的解决方案标记为我的问题的答案,因为总体思路是相同的,只需在 Xcode 中为其创建一个专用 UI​​。

回答by Stavash

The easiest solution for your needs - launch your application, take a screenshot of the initial state (home+power button on the device), and voila! You have yourself a nice png file containing your initial app state with Apple's color scheme as needed.

满足您需求的最简单解决方案 - 启动您的应用程序,截取初始状态(设备上的主页 + 电源按钮),瞧!您有一个漂亮的 png 文件,其中包含您根据需要使用 Apple 配色方案的初始应用程序状态。

回答by hotpaw2

I ifdef out my data source in a debug build so the app starts up empty, then build and run it, and take a screenshot of the empty app. To suggest that the user wait a bit, I might use photoshop to overlay my trademark image or some splash logos partially blocking the most obvious control. If it's an entertaining app, I might also animate a copy of those logo icons away when the app starts running.

我在调试版本中定义了我的数据源,以便应用程序启动时为空,然后构建并运行它,并截取空应用程序的屏幕截图。为了建议用户稍等片刻,我可能会使用 photoshop 来覆盖我的商标图像或一些飞溅的徽标,部分地阻挡了最明显的控件。如果它是一个有趣的应用程序,当应用程序开始运行时,我还可以将这些徽标图标的副本制作成动画。

回答by Joshua Hart

Easier even than that. Pull up the image you want to put as your splash screen on your phone. Save the image to your camera roll. Open the image in your camera roll. Tap on the image to get a full screen view. Take a screen shot. Send that image, via email to your computer. Change the ending of the file from PNG to png, it sucks I know :) Add the image to your Launch Image area. Walla! ;)

甚至比这更容易。拉出您想要作为手机启动画面的图像。将图像保存到您的相机胶卷。打开相机胶卷中的图像。点击图像以获得全屏视图。截屏。通过电子邮件将该图像发送到您的计算机。将文件的结尾从 PNG 更改为 png,我知道这很糟糕:) 将图像添加到您的启动图像区域。瓦拉!;)

回答by Doug Richardson

You can use iOS 8 launch screen XIBs to generate static launch images using the simulator, which you may have to do if you're supporting iOS 7 or earlier.

您可以使用 iOS 8 启动屏幕 XIB 使用模拟器生成静态启动图像,如果您支持 iOS 7 或更早版本,则可能必须这样做。

  1. Create a launch screen XIB.
  2. Select the project itself in Xcode's project navigator and then under General > Deployment Infochange the Main Interfacefield to your launch screen XIB. This step will leave the launch screen XIB in the Simulator so you have time to take a screen shot in step 4.
  3. Start your application in the Simulator.
  4. Once your launch screen appears in the Simulator, select File > Save Screen Shot.
  1. 创建启动屏幕 XIB。
  2. 在 Xcode 的项目导航器中选择项目本身,然后在General > Deployment Info 下Main Interface字段更改为您的启动屏幕 XIB。此步骤将在模拟器中保留启动屏幕 XIB,以便您有时间在步骤 4 中截取屏幕截图。
  3. 在模拟器中启动您的应用程序。
  4. 一旦您的启动屏幕出现在模拟器中,选择File > Save Screen Shot

Repeat this process for each device you need to support. You may have to use an image editor to remove the status bar from the screen shot.

对您需要支持的每个设备重复此过程。您可能需要使用图像编辑器从屏幕截图中删除状态栏。

回答by juancazalla

If you need a simple launch screen with a navigation bar and a tab bar for example, my suggestion is to use launch files. In iOS 8 and later, you can create a XIB or storyboard file instead of a static launch image.

例如,如果您需要一个带有导航栏和标签栏的简单启动屏幕,我的建议是使用启动文件。在 iOS 8 及更高版本中,您可以创建 XIB 或故事板文件而不是静态启动图像。

You can read more about that in the next link: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LaunchImages.html

您可以在下一个链接中阅读更多相关信息:https: //developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LaunchImages.html

回答by Jon Hallam

I Set all the above. however it didn't work when debugging again. I remove the app from the simulator and iPhone and worked straight away

我设置了以上所有内容。但是再次调试时它不起作用。我从模拟器和 iPhone 中删除了应用程序并立即开始工作