Why does a view changes position when rotating it using CGAffineTransformMakeRotation

前端 未结 3 1344
执念已碎
执念已碎 2021-02-12 21:35

I have the following super simple animation, I\'m basically rotating a view 2 radians from its original angle/center, it rotates fine my only misunderstanding is why does the vi

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-12 22:17

    The "anchor" of CGAffineTransformMakeRotation is the X,Y of the view. You can try this:

    CGPoint center = self.someView.center;
    [UIView animateWithDuration:1.0 animations:^{
        self.someView.transform = CGAffineTransformMakeRotation( 2 );
        self.someView.center = center;
    }];
    

提交回复
热议问题