I have UIButton
, that i wish to rotate in one direction for 180 degrees, and back also for 180 degrees. I have been doing animations for a while using CABasicAnimation
, but this time i wanted to do it with transforms. Here is the code that i have written:
- (IBAction)blurAction:(id)sender {
if (self.blurActive) {
[UIView animateWithDuration:0.1 animations:^{
self.blurView.alpha = 0;
self.blurButton.transform = CGAffineTransformMakeRotation(M_PI);
} completion:^(BOOL finished) {
self.blurActive = NO;
}];
}
else {
[UIView animateWithDuration:0.1 animations:^{
self.blurView.alpha = 1;
self.blurButton.transform = CGAffineTransformMakeRotation(-M_PI);
} completion:^(BOOL finished) {
self.blurActive = YES;
}];
}
}
It works the first time, but second time i press the button, nothing happens. Can someone explain what I am doing wrong here?