2

我有一个 UIView,我想在给定的 T 时间内围绕它的中心点旋转 N 次。并且旋转的速度应该逐渐降低。(像一个旋转轮)。我有下面的代码,它不能正常工作。

   float T = 5; // 5 seconds
   float rotations = 10;
   //_containerView is the view to be rotate

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:T];
    [UIView setAnimationRepeatCount:0];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    CGAffineTransform t = CGAffineTransformRotate(_containerView.transform, (2*M_PI*rotations + 0));
    _containerView.transform = t;
    [UIView commitAnimations];
4

1 回答 1

0
#define StartAnimation(duration) [UIView beginAnimations:nil context:NULL];    \
[UIView setAnimationDuration:duration];       \
[UIView setAnimationRepeatAutoreverses:NO];   \
[UIView setAnimationRepeatCount:0]

#define StopAnimation [UIView commitAnimations]

定义这些宏并使用

StartAnimation(<time>)
//your code
StopAnimation
于 2013-01-09T17:31:10.710 回答