I've got a scrollView app. And each scrollView item has it's own title (navigationItem title). Now when user does something(I have a way of capturing this event) on a particular scrollView item I want to animate the navigation item.
I was thinking maybe changing it's background color continuously or something or maybe better increase/decrease it's transparency if possible.
Has anyone done something similar to this? What would be the right approach to do this? I don't have a script requirement what I need to do, just that the current scrollView item(view) is different from others.
Thanks for any suggestions
I got it from the response I received :
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration=1.5;
animation.repeatCount=1000000;
animation.autoreverses=YES;
animation.fromValue=[NSNumber numberWithFloat:1.0];
animation.toValue=[NSNumber numberWithFloat:0.3];
[button addAnimation:animation forKey:@"animateOpacity"];
it's not too fast and intensive to cause a seizure I hope
UIBarButtonItem (annoyingly) does not inherit from UIView, so CoreAnimation would do diddly squat if you tried it. However, if you rolled your own navigation item with a UIButton
and a UIImageView
set as the customView
property, then animation is entirely possible with UIView's block animation wrapper:
[UIView animateWithDuration:1.0f animations:^{
[myButton setAlpha:0.0f];
//the button is now invisible
}];
As for color animations, unfortunately, only CGColors may be animated, and then, only under very sketchy circumstances.