1

嗨,我正在开发一个应用程序,它需要两个角度之间的图像动画。即从 0-90 度,然后在图像达到 0 度后 90-0 度,动画必须停止。

我正在使用以下代码,它仅提供 0-90 的动画,但我还需要使用 90 的动画将图像设置为 0。

               [UIView animateWithDuration: 0.5f
                     delay: 0.0f
                   options: options
                animations: ^{
                   self.imageToMove.transform = CGAffineTransformRotate(imageToMove.transform, M_PI / 2);
                }
                completion: ^(BOOL finished) {
                   if (finished) {
                         // if flag still set, keep spinning with constant speed
                         [self spinWithOptions: UIViewAnimationOptionCurveLinear];
                      } 
                   }
                }];

任何帮助请......

4

1 回答 1

1

通过更改“RADIANS”的值来试试这个

    #define RADIANS(degrees) ((degrees * M_PI) / 180.0)

//- (void)startWobble 

-(IBAction)start:(id)sender

{

    itemView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-1));

    [UIView animateWithDuration:0.15 delay:0.0 options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)

                     animations:^ {

                         itemView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(1));

                     }

                     completion:NULL

     ];

}

//- (void)stopWobble 

-(IBAction)end:(id)sender

{

    [UIView animateWithDuration:0.25

                          delay:0.0 

                        options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)

                     animations:^ {

                         itemView.transform = CGAffineTransformIdentity;

                     }

                     completion:NULL

     ];

}
于 2013-01-02T08:48:02.880 回答