简体   繁体   中英

How to add a gradient background with LaunchScreen.storyboard?

I want to add a gradient background to LaunchScreen.storyboard. Since this gradient changes with the diagonal of the screen, it is difficult for UIImageView to support screens with different aspect ratios.

So far, Launch Image was used to solve this. However, Apple enforces the use of LaunchScreen.storyboard.

How do I add this to LaunchScreen.storyboard?

Thanks.

在此处输入图片说明

Use an image editor (or whatever suits you) to create that as an image.

You can then add a UIImageView to your LaunchScreen.storyboard (Content Mode: Scale to Fill).


Edit

LaunchScreen storyboards cannot execute any code - and that includes trying to use a custom subclass.

If scaling a single image doesn't suit your needs, you do have a (limited) option.

UIImageView - including when used in a LaunchScreen - can have different images for different size traits:

在此处输入图片说明

You cannot get down to actual screen sizes, but using different images for the different trait combinations might do the trick.

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