I have TagView which is subclass of UIView. I'm rotating it around anchor point like so:
double rads = DEGREES_TO_RADIANS(self.angle);
[self setAnchorPoint:self.anchor forView:self];
CGAffineTransform transform = CGAffineTransformRotate(CGAffineTransformIdentity, rads);
self.transform = transform;
I'm setting anchor point using method proposed 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;
}
I had an Auto Layout issue which I have fixed by placing my view into container UIView and setting it into center. But when I change the content of label which is inside my View it makes jump.