1
我加入一个CALayer
作为子层的UIView
的layer
属性,如下所示:将子图层添加到view.layer会更改帧的位置?
_graphicLayer = [[GraphicLayer alloc] init];
self.bounds = _graphicLayer.bounds;
_graphicLayer.position = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
[self.layer addSublayer:_graphicLayer];
正如你所看到的,我改变位置_ graphicLayer
占居中anchorPoint
。我注意到添加了这个子图层后,它将视图frame
更改为(-self.bounds.width/2, -self.bounds.height/2)
。这是为什么发生?如果我改变_ graphicLayer
的位置,我认为这只是相对于其父视图。为什么会影响frame
属性的意见? (我不想调整视图图层属性或_graphicLayer
的anchorPoint)。