问题描述
我将 CAGradientLayer
添加到 UIVIew
,当我向设备旋转视图时添加到大小增加(使用自动布局)但是CA层不会更改其大小。
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.
我已尝试实现 viewDidLayoutSubviews
方法并在那里设置图层框架,但它没有任何区别。
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.
推荐答案
你可以覆盖 - (void)layoutSubviews
在你的UIView子类中,然后更新图层框架。
You could override - (void)layoutSubviews
in your UIView subclass and then update the layers frame.
这篇关于CAGradientLayer不会改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!