Setting gradient background color to LaunchScreen which will display a logo image at center

Viewed 11354

I have a requirement to set a Gradient background to the launch screen with a UIImageView in the center which shows the app logo . I tried having a view controller but I realised code will never be invoked.

I need some way to get behaviour as the code below does

self.view.backgroundColor = UIColor(patternImage: UIImage(named: "background.png")!)

I went through lot of answers about the same topic, most of the questions on gradient colour don't seem to have any additional requirements like showing another image other than the background .

I can hardcode the color in IB but i don't get the gradient.

2 Answers

You can use 2 layers of UIImageView:

The first is large and contain the background gradient image, and a second layer of centered image (with transparent backgrount) of the logo.

Related