Set gradient color in swift

func applyGradient(colours: [UIColor]) -> Void {
        let gradient: CAGradientLayer = CAGradientLayer()
        gradient.frame = CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT)
        gradient.colors = colours.map { $0.cgColor }
        gradient.opacity = 0.3
        //gradient.startPoint = CGPoint(x: 1, y: 0)
        self.layer.insertSublayer(gradient, at: 0)
    }

override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.view.applyGradient(colours: [UIColor.red, UIColor.orange])
    }