Skip to content

Instantly share code, notes, and snippets.

@EricADockery
Created June 16, 2018 12:52
Show Gist options
  • Save EricADockery/413c89af68dab0cdbda42e54014541ef to your computer and use it in GitHub Desktop.
Save EricADockery/413c89af68dab0cdbda42e54014541ef to your computer and use it in GitHub Desktop.
class GradientView: UIView {
override func awakeFromNib() {
super.awakeFromNib()
let gradientLayer = CAGradientLayer()
gradientLayer.frame = CGRect(x: 0, y: 0, width: frame.width, height: frame.height)
gradientLayer.colors = [UIColor.white.cgColor,UIColor.red.withAlphaComponent(0.5).cgColor]
gradientLayer.startPoint = CGPoint(x: 0.0, y: 1.0)
gradientLayer.endPoint = CGPoint(x: 1.0, y: 1.0)
layer.addSublayer(gradientLayer)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment