user9383160
user9383160

Reputation:

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.

enter image description here

Upvotes: 3

Views: 9069

Answers (1)

DonMag
DonMag

Reputation: 77476

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:

enter image description here

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

Upvotes: 4

Related Questions