旋转视图并同时移动其位置的最佳方法是什么?
我希望这个视图在向左滑动时旋转一整圈,然后在滑回其原始位置时旋转另一个方向。我完成了这项工作的第一部分(向左滑动时旋转),但是当我尝试在向右滑动时旋转时,视图会跳回其原始位置而没有动画。
我究竟做错了什么?
// step 1 (this works)
[UIView animateWithDuration:0.3f animations:^{
self.number.transform = CGAffineTransformMakeRotation(DegreesToRadians(180));
self.number.transform = CGAffineTransformMakeTranslation(-160, 0);
self.number.center = CGPointMake(self.number.center.x - 160, self.number.center.y);
} completion:nil];
// step 2 (this doesn't work)
[UIView animateWithDuration:0.2f animations:^{
self.number.transform = CGAffineTransformMakeRotation(DegreesToRadians(180));
self.number.transform = CGAffineTransformMakeTranslation(160, 0);
self.number.center = CGPointMake(self.number.center.x + 160, self.number.center.y);
} completion:nil];