I am trying to set the background on my UIView to a gradient.  I have the following in my UIViewController's viewDidLoad method:
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [UIColor.blue70.cgColor, UIColor.blue60.cgColor, UIColor.blue70.cgColor]
gradientLayer.startPoint = CGPoint(x: 0, y: 0)
gradientLayer.endPoint = CGPoint(x: 1, y: 1 )
gradientLayer.frame = self.view.bounds
self.view.layer.insertSublayer(gradientLayer, at: 0)
The gradient renders as expected.  However, when I rotate the device the gradient does not redraw and is no longer rendered properly.  Rotating from portrait->landscape leaves me with a blank section on the right or left.  Rotating from landscape->portrait leaves me with a blank section at the bottom.  I tried moving this code to viewDidLayoutSubviews, but that didn't solve it.  Any recommendations on how to accomplish this?
 
     
     
    