您正在开发一个需要两个角度之间的图像动画的应用程序。在图像达到0度后,从0-90然后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];
}
}
}];
请帮助....
答案 0 :(得分: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
];
}