因为您已将动画设置为角度 (180 * M_PI / 180),所以如果您设置相同的角度,它将永远不会再次弹起。
尝试这个
CGFloat t = 180*M_PI / 180.0;
CGAffineTransform translateSpring = CGAffineTransformRotate(CGAffineTransformIdentity, t);
[UIView animateWithDuration:0.7 delay:0.0 options:nil animations:^{
imageView.transform = translateSpring;
} completion:^(BOOL completed) {
if (completed && stillReloading) {
//Use this method to let it spring back to its original angle
[UIView animateWithDuration:0.07 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
imageView.transform = CGAffineTransformIdentity;
} completion:NULL];
[self performSelector:@selector(animation) withObject:nil afterDelay:0.2];
}
}];
或者,您还可以为要转换的 imageView 设置动态更新角度。看看有没有帮助:)
根据您的问题,您可以查看我的代码,这里我使用动画将视图更改回其身份转换:
if (completed && stillReloading) {
//Use this method to let it spring back to its original angle
[UIView animateWithDuration:0.07 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
imageView.transform = CGAffineTransformIdentity;
} completion:NULL];
[self performSelector:@selector(animation) withObject:nil afterDelay:0.2];
}
// So if you want to transform it without getting seen, you can simply detele the animation code
if (completed && stillReloading) {
imageView.transform = CGAffineTransformIdentity;
[self performSelector:@selector(animation) withObject:nil afterDelay:0.2];
}