I am trying to make a "refresh" animation using a UIBarButtonItem, the problem is that is not only rotating but moving the image up and down a bit.
-(void)startRefreshButtonRotationAnimation {
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1000;
UIView *view = self.navigationItem.rightBarButtonItem.customView;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
- (void)stopRefreshButtonRotationAnimation {
UIView *view = self.navigationItem.rightBarButtonItem.customView;
[view.layer removeAllAnimations];
}