简体   繁体   中英

Use static image for launch image iOS 9 from Asset Catalog

I'm trying to use a static image on my LaunchScreen.storyboard , so we need unique sizes for each device.

In my assets folder I can great a launch image Image Set that allows me to add images for each device, however I just get a blank launch image when I use these in an Image View . A regular image doesn't give enough options (only 1x, 2x, 3x for iPhone/iPad). What's the best way to do this?

To clarify: how can I use a full screen static image that fits on say both a 4S and iPhone 5 when both those images are technically 2x? Creating a new launch images asset gives all these options for different screen sizes, however it can't be used in storyboard as an image like a regular asset.

Instead of using the LaunchImage set, add a normal image set of the image that you want to be on the launch screen to your .xcassets file. Next, add a UIImageView to the UIViewController in your LaunchScreen.storyboard and set the image using the Attribute Inspector.

Step 1: Add your image assets to the .xcassets file

将资产添加到.xcassets文件

Step 2: Add a UIImageView to the LaunchScreen.storyboard file

将UIImageView添加到LaunchScreen.storyboard文件

Step 3: Add constraints to the UIImageView and set the image in the Attribute Inspector

BTW , don't forget to make sure that the Launch Screen File in your .xcodeproj is set to your LaunchScreen starboard file!

确保您的.xcodeproj文件中的文件正确!

You should now be good to go!

UPDATE: Static Launch Image using only the .xcassets file

If you want to use a full screen static image on launch, you can use just a LaunchImage set in your .xcassets file.

If you don't already have a .xcassets file in your project, add a new file like so: File > New > File > iOS Resource > Asset Catalog.

将启动映像集添加到.xcassets文件

Next, open your .xcassets file and right click > App Icons & Launch Images > New iOS Launch Image

添加特定的启动屏幕图像

Now you can add specific launch images for iPhone 4(S), 5(S/C), 6(S) and 6(S) Plus. (BTW, I've selected only the portrait orientation for this image set).

将启动屏幕字段保留为空白

The last, and very important step, is to leave the Launch Screen File field in blank in your target settings!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM