Guest User

Untitled

a guest
Jun 25th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. func applyGradient(colours: [UIColor]) -> Void {
  2. let gradient: CAGradientLayer = CAGradientLayer()
  3. gradient.frame = self.bounds
  4. gradient.colors = colours.map { $0.cgColor }
  5. self.layer.insertSublayer(gradient, at: 0)
  6. }
  7.  
  8. func applyGradientToView(){
  9. let firstColor = UIColor(red: 26/255, green: 169/255, blue: 186/255, alpha: 1.0)
  10. let secondColor = UIColor(red: 26/255, green: 97/255, blue: 157/255, alpha: 1.0)
  11. let thirdColor = UIColor(red: 27/255, green: 65/255, blue: 144/255, alpha: 1.0)
  12. self.applyGradient(colours: [firstColor, secondColor, thirdColor])
  13. }
Add Comment
Please, Sign In to add comment