【发布时间】:2013-01-06 05:50:40
【问题描述】:
我将CALayer 作为子层添加到UIView 的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。
【问题讨论】:
标签: iphone ios cocoa-touch core-animation calayer