How to detect a change in orientation after it happened with Swift 3?
I need to detect it after the change in order to calculate the frame size.
EDIT
I asked this question because I need to redraw the idea of ββa change in orientation, as in this question: I canβt get a background gradient to fill the entire screen when rotating
I do not know how to implement the answer marked as the correct answer.
I tried a different answer
self.backgroundImageView.layer.sublayers?.first?.frame = self.view.bounds
but it does not work.
In viewDidLoad()i have
let color1 = UIColor(red: 225.0/255.0, green: 210.0/255.0, blue: 0.0/255.0, alpha: 1.0).cgColor
let color2 = UIColor(red: 255.0/255.0, green: 125.0/255.0, blue: 77.0/255.0, alpha: 1.0).cgColor
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [color1, color2]
gradientLayer.locations = [ 0.0, 1.0]
gradientLayer.frame = self.view.bounds
self.view.layer.insertSublayer(gradientLayer, at: 0)
source
share