Apply gradient created in Sketch to Xcode View Controller

Hi everyone, i'm creating a project in Xcode with a red gradient background. I created the gradient in Sketch and now i'm not sure how to convert it to Xcode. The top of the gradient is:


Hex: FB8189

R: 251

G: 129

B: 137

A: 100


and the bottom is:


Hex: C02128

R: 192

G: 33

B: 40

A: 100


I've already got a lot of my project completed using imports from Sketch but this one requires me to code the gradient background. Could someone help me with the start to finish process for applying this gradient to the View Controller?

Accepted Reply

Here's a starting point: CAGradientLayer from the CoreAnimation framework is an easy way to create a gradient.


If you search the forums for it, or google it, you can probably find some Swift code to help you set it up with your view controller.

Replies

Here's a starting point: CAGradientLayer from the CoreAnimation framework is an easy way to create a gradient.


If you search the forums for it, or google it, you can probably find some Swift code to help you set it up with your view controller.

I managed to work this out now using a CAGradientLayer. Thanks