我正在将指针指向12点到当前时间。如果是11点,我想让手臂顺时针旋转到11点钟的位置。但当然,如果我使用:顺时针旋转UIView以获得大于180度的角度
CGAffineTransform rotation = CGAffineTransformMakeRotation(2*M_PI*11/12);
[UIView animateWithDuration:3.0
animations:^{
clockArm.transform = rotation;
}];
旋转逆时针旋转。我想:
CGFloat angle = 2*M_PI*11/12;
CGAffineTransform firstRotation = CGAffineTransformMakeRotation(M_PI-0.001);
CGFloat firstRotationTime = 3.0*(M_PI/angle);
CGAffineTransform secondRotation = CGAffineTransformMakeRotation(angle);
CGFloat secondRotationTime = 3.0 - firstRotationTime;
[UIView animateWithDuration:firstRotationTime
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
self.clockArm1.transform = firstRotation;
}
completion:^(BOOL finished) {
[UIView animateWithDuration:secondRotationTime
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
self.clockArm1.transform = secondRotation;
}
completion:^(BOOL finished){
}];
}];
动画并顺时针走,却是波涛汹涌 - 动画仍然似乎是在做一个UIViewAnimationEaseInOut第一个动画。我做错了什么,还是有另一种方法来实现我想要的?
看一看http://stackoverflow.com/questions/9844925/uiview-infinite的接受的答案-360度旋转的动画。这有帮助吗? –