This blog post is a great read and I wanted to use the code they talk about there. I suggested they upload the code to the open-source community, but I got no response. So I have taken the code directly from that blog post and uploaded it here, for all to use.
let colors = [
UIColor.black.cgColor,
UIColor.white.cgColor
]
let gradientView = GradientView(colors, .rightLeft)