问题
I have a CAGradientLayer which is added to a UIVIew, when I rotate the device the view that it is added to increases in size (with autolayout) however the CA layer doesn't change its size.
I have tried implementing the viewDidLayoutSubviews method and setting the layers frame in there but it doesn't make any difference.
Once the device is rotated if I navigate away from the view and then back to it then the layer gets drawn correctly.
回答1:
You could override - (void)layoutSubviews in your UIView subclass and then update the layers frame.
来源:https://stackoverflow.com/questions/33414131/cagradientlayer-bounds-not-changing