Question

I've customized my Custom UINavigationBar to show a custom image (actually I crossfade between lots of images on a NSTimer) :

- (void) displayImage:(EGOImageView*)anImageView {
    CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:@"contents"];
    crossFade.duration = 0.5;
    crossFade.fromValue = self.layer.contents;
    crossFade.toValue = (id)[self imageFromView:anImageView].CGImage;
    [self.layer addAnimation:crossFade forKey:@"animateContents"];
    self.layer.contents = (id)[self imageFromView:anImageView].CGImage;
}

How do I prevent the navigationBar to loose my custom layer when enabling or disabling a barButtonItem? My navigation bar goes back to it's default state after the following line in my VC is executed:

self.navigationItem.rightBarButtonItem.enabled = !editing;

(It reverts to the UIBarStyleBlackOpaque I've set in the VC's viewDidLoad)

Was it helpful?

Solution

When I was working on a custom NavBar i found this useful How do iPhone apps Instagram/Reeder/DailyBooth implement custom NavigationBars with variable width back buttons?

It goes across how to make a custom NavBar, and then later on talks about a past post, about to make a custom back button. Which is a full post which can be found here. I personally found these useful in my current project. Hopefully this will either explain why it's happening for your method, or give you an alternative method to use, if you can't find a solution for your current method of using crossFade and NSTimer

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top