Skip to content

Instantly share code, notes, and snippets.

@jimmythai
Created July 13, 2017 01:12
Show Gist options
  • Select an option

  • Save jimmythai/6d08dc100dac4990efc73519d95eb4dc to your computer and use it in GitHub Desktop.

Select an option

Save jimmythai/6d08dc100dac4990efc73519d95eb4dc to your computer and use it in GitHub Desktop.
let frame = CGRect(x: 0, y: 0, width: 380, height: 600)
let view = UIView(frame: frame)
let gradient = CAGradientLayer()
gradient.frame = frame
gradient.colors = [UIColor.blue.cgColor, UIColor.green.cgColor]
gradient.startPoint = CGPoint(x: 0.408, y: 0)
gradient.endPoint = CGPoint(x: 0.746, y: 1)
view.layer.addSublayer(gradient)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment