.

Чтение книги онлайн.

Читать онлайн книгу - страница 4

Автор:
Жанр:
Серия:
Издательство:
 -

Скачать книгу

for iPhone-based and iPad-based applications.

Table 1.1 Home Screen Icon Sizes

      You learn to use these icons in this lesson's Try It section.

      Application Launch Image

      A launch image is a placeholder image that you must provide as part of your iOS application. When a user taps your application's icon on the home screen, iOS displays this image while the app starts up.

      Once your application has finished loading, iOS gives it control and simultaneously hides the launch image. The overall effect of the launch image is to give your users the perception that your application has launched quickly.

      NOTE

      The launch image provided as part of your application may not always be used. When an app is suspended into the background state (perhaps because the user tapped the home button on the device), iOS creates a snapshot of the current screen before suspending the app. If the app is resumed within a short period of time then this cached image is used in place of the launch image. However, if the user killed the app, uninstalled it, or hasn't used the app for an extended period of time then the launch image will be used.

      Prior to iOS8, as a developer you had to provide a static PNG version of the launch image for every screen size and orientation that was supported by your app.

      While it is still possible to provide static launch images, with the launch of iOS 8 Apple has introduced the concept of a single launch file. A launch file is an XIB (or a storyboard file) that describes the user interface for the launch image. An empty document called LaunchScreen.storyboard is provided with every iOS project that you create.

      The idea behind providing a single launch file over several individual launch images is that iOS will generate the launch images it needs from the launch file for the device on which the app is being used.

      You learn to use a launch file in this lesson's Try It section.

      TRY IT

      In this Try It, you build a simple iPhone application using Xcode 7 that displays the text “Hello Swift” in the center of the screen. You will also provide application icons and a launch file.

      Lesson Requirements

      • Launch Xcode.

      • Create a new project based on the Single View Application template.

      • Edit a storyboard in Interface Builder.

      • Display the Xcode Utilities area.

      • Set up an application icon.

      • Set up a launch file.

      • Test an app in the iOS Simulator.

      REFERENCE

      The code for this Try It is available at www.wrox.com/go/swiftios.

      Hints

      Download and install the latest version of Xcode and the iOS SDK on your Mac; then launch Xcode.

      Step-by-Step

      • Create a Single View Application in Xcode called HelloSwift.

      1. Launch Xcode.

      2. To create a new project, select the File arrow New arrow Project menu item.

3. Choose the Single View Application (see Figure 1.5) template for iOS and click Next.

Figure 1.5

4. Use the following information in the project options dialog box (see Figure 1.6) and click Next.

      • Product Name: HelloSwift

      • Organization Name: Your company

      • Organization Identifier: com.wileybook

      • Language: Swift

      • Devices: Universal

      • Use Core Data: Unchecked

      • Include Unit Tests: Unchecked

      • Include UI Tests: Unchecked

Figure 1.6

      5. Select a folder where this project should be created.

      6. Ensure the Source Control checkbox is not selected.

      7. Click Create.

• Edit the Main.storyboard file in Interface Builder (see Figure 1.7).

Figure 1.7

      1. Ensure the project navigator is visible and the HelloSwift project is selected and expanded. To show the project navigator, use the View arrow Navigators arrow Show Project Navigator menu item. To expand a project, click the triangle next to the project name in the project navigator.

      2. Click the Main.storyboard file to select it.

      3. Ensure the Attribute inspector is visible by selecting the View arrow Utilities arrow Show Utilities menu item.

      4. Click the white background area of the default scene in the storyboard.

5. Under the View section of the Attribute inspector, click once on the Background item to change the background color. This is shown in Figure 1.8. Pick any color you want.

Figure 1.8

6. From the Object library in the bottom-right corner, select Label and drop it onto the View (see Figure 1.9). You can use the search box to narrow your choices.

Скачать книгу