Quickly setup a gradient and animate it too! wow! dope stuff!

I’ve made a video tutorial on this exact story found on my youtube channel, if you prefer to watch instead of read!

What is CAGradientLayer?

The Apple Developer docs on CAGradientLayer describe it as a subclass of CALayer with a color gradient drawn upon it. Or as exactly stated by the docs:

A layer that draws a color gradient over its background color, filling the shape of the layer (including rounded corners) — Apple Developer Docs

Alright, so to avoid copying and pasting the entire CAGradientLayer documentation over to medium, how about we write some code to fill your mind with the possibilities of animating a CAGradientLayer!

Quick Setup! This gives you a nice gradient!