You can achieve this effect by using a CAGradientLayer
with startPoint
and endPoint
properties to define the direction of the gradient.
Here's an example code snippet:
main.swift474 chars10 lines
This code creates a CAGradientLayer
with three colors that blend from white to light blue and finally to light purple. The locations
array specifies where each color starts and stops in the gradient, and the startPoint
and endPoint
properties define the direction of the gradient.
You can adjust the colors and locations to get the exact gradient you want, and use this layer as the background for any view.
gistlibby LogSnag