1

I wanted to Mix two colors shaded and divided equally.

enter image description here

(Ignore the buttons inside of it) Also, I want to apply this functionality somewhere horizontally and somewhere vertically.

Thank you.

Nirav D
  • 71,513
  • 12
  • 161
  • 183
vivek agravat
  • 251
  • 2
  • 10
  • You could use a `CAGradientLayer`, like this: http://stackoverflow.com/questions/24380535/how-to-apply-gradient-to-background-view-of-ios-swift-app – ganzogo Nov 25 '16 at 07:14

1 Answers1

2

The way you are looking for is CAGradientLayer.

For Vertical

let gradientLayer = CAGradientLayer()
gradientLayer.frame = self.gradientView.bounds
gradientLayer.colors = [UIColor.red.cgColor, UIColor.blue.cgColor] //Add different color here
self.gradientView.layer.addSublayer(gradientLayer) //Add Layer in your View

For Horizontal simply set startPoint and endPoint with gradientLayer.

gradientLayer.startPoint = CGPoint(x: 0, y: 0.5)
gradientLayer.endPoint = CGPoint(x: 1, y: 0.5)
Nirav D
  • 71,513
  • 12
  • 161
  • 183