Gradients in Swift
How gradual is this?
To add gradient effects to views you deal with the sublayer of the UIView, rather than the UIView itself. But how does this work when we want to add gradients and us the mysterious gradient Locations.
- Some knowledge of CoreGraphics would be useful
CAGradientLayer: A layer that draws a colour gradient over its background colour
Locations: The location where a gradient stopsBackground
Locations are where gradient stop.
For example, in the first view above the red gradient begins at 0 (the top), and ends at 0.5 (the center).
1 is at the bottom of the relevant view.
Sample code to achieve the gradients above:
A GitHub link for this project:
Gradients for Swift. Contribute to stevencurtis/Gradients development by creating an account on GitHub.
Want to get in contact? Try the link here: