Problem:
I would like to set two different background colors for a view controller programmatically.
Code:
self.view.backgroundColor = .systemBackground
or
func setGradientBackground() {
let colorTop = UIColor.black.cgColor
let colorBottom = backgroundGray.cgColor
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [colorTop, colorBottom]
gradientLayer.startPoint = CGPoint(x: 0, y: 0)
gradientLayer.endPoint = CGPoint(x: 1, y: -1)
//gradientLayer.locations = [0.0, 1.0]
gradientLayer.frame = self.view.bounds
self.view.layer.insertSublayer(gradientLayer, at:0)
}
Do I need to use a gradient system to obtain this? The gradient system is well gradient and I would like more of a solid top and bottom color.