Xcode 5 & Asset Catalog: How to reference the LaunchImage?

前端 未结 14 1579
萌比男神i
萌比男神i 2020-11-28 18:17

I am using Xcode 5\'s Asset Catalog, and I would like to use my LaunchImage as the background image of my home view (a pretty common practice to make the transi

14条回答
  •  天命终不由人
    2020-11-28 18:39

    I realize that this is not necessarily the best solution for everyone but the easiest (and least error-prone, IMHO) way to do this is by making a separate entry in your Images.xcassets catalog. I called it SplashImage.

    When you go to add a new entry, make sure not to select "New Launch Image" as an option. Instead, select the generic "New Image Set". Next, open up the inspector and select the relevant options. If you're building for only retina devices, as I was, you can select the following:

    image inspector

    This will leave you with four entries (iPhone 4S, iPhone 5(s,c), iPhone 6, and iPhone 6 Plus).

    images

    The files corresponding the the images are as follows:

    | Resolution (Xcode entry) | Launch Image name   |   Device         |
    |--------------------------|---------------------|------------------|
    | 1x                       | Default-750.png     | iPhone 6         |
    | 2x                       | Default@2x.png      | iPhone 4S        |
    | Retina 4 2x              | Default-568h@2x.png | iPhone 5, 5s, 5c |
    | 3x                       | Default-1242.png    | iPhone 6 Plus    |
    

    Of course, after you've done this you can simply use [UIImage imageNamed:@"SplashImage"]

提交回复
热议问题