我有UIView的子类TagView。我围绕锚点旋转它,如下所示:
double rads = DEGREES_TO_RADIANS(self.angle);
[self setAnchorPoint:self.anchor forView:self];
CGAffineTransform transform = CGAffineTransformRotate(CGAffineTransformIdentity, rads);
self.transform = transform;我正在使用提议的here:方法设置锚点
- (void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view {
CGPoint newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x,
view.bounds.size.height * anchorPoint.y);
CGPoint oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x,
view.bounds.size.height * view.layer.anchorPoint.y);
newPoint = CGPointApplyAffineTransform(newPoint, view.transform);
oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform);
CGPoint position = view.layer.position;
position.x -= oldPoint.x;
position.x += newPoint.x;
position.y -= oldPoint.y;
position.y += newPoint.y;
view.layer.position = position;
view.layer.anchorPoint = anchorPoint;
}我有一个自动布局的问题,我已经修复了,通过将我的视图放在容器UIView中并将其设置在中心。但是当我改变我视图中的标签的内容时,它会跳转。

https://stackoverflow.com/questions/51266390
复制相似问题