我有一个 UIView
,其中添加了大约 8 个不同的 CALayer
子层。
如果我修改了 View 的边界(动画),那么 View 本身会缩小(我用 backgroundColor
检查了它),但子层的大小保持不变强>。
如何解决?
最佳答案
我使用了与 Solin 相同的方法,但该代码中有一个错字。方法应该是:
- (void)layoutSubviews {
[super layoutSubviews];
// resize your layers based on the view's new bounds
mylayer.frame = self.bounds;
}
出于我的目的,我一直希望子图层与父 View 一样大。将该方法放在您的 View 类中。
https://stackoverflow.com/questions/2504151/