很簡單:
[UIView beginAnimations:@"rotate" context:nil];
[UIView setAnimationDuration:.25f];
if(CGAffineTransformEqualToTransform(button.imageView.transform,CGAffineTransformIdentity)){
button.imageView.transform = CGAffineTransformMakeRotation(M_PI);
}else {
button.imageView.transform =CGAffineTransformIdentity;
}
[UIView commitAnimations];
這樣就可以做到點選時旋轉180°,再點選時再轉回來。
其他動畫同理。