我有这个功能可以将 UIButtons 旋转 45 度。但是一旦旋转,调用相同的方法不会再旋转,并且按钮在第一次旋转后卡在其旋转位置。有任何想法吗?
- (void)rotateImage:(UIButton *)image duration:(NSTimeInterval)duration
curve:(int)curve degrees:(CGFloat)degrees
{
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix
CGAffineTransform transform =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
image.transform = transform;
// Commit the changes
[UIView commitAnimations];
}