Carlos Guzman
Carlos Guzman

Reputation: 429

Custom animation for UINavigationBar setItems/ pushNavigationItem / popNavigationItem?

I'm using a UINavigationBar in a regular UIViewController (not a UINavigationController) and updating the contents of the navigation bar using setItems:animated, pushNavigationItem:animated and popNavigationItem:animated, with animated set to YES. Works fine, except that I would like the crossfade animation of the navigation bar, rather than the built-in animation which "pushes" the previous bar to left or right.

So far the only way I can see how to do this would be to manually set the title, left and right contents of the bar, using setLeftBarButtonItems:animated, setRightBarButtonItems:animated and probably a custom view for the title with setTitleView so that I can do the crossfade. Anybody has a better solutions to my problem?

Upvotes: 2

Views: 755

Answers (1)

dalton_c
dalton_c

Reputation: 7171

Just tried this and it worked:

[UIView transitionWithView:self.navBar duration:2.0f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{

        myNavigationItem.leftBarButtonItem = newLeftItem;
        myNavigationItem.rightBarButtonItem = newRightItem;
        myNavigationItem.title = @"My New Title";
    } completion:nil];

Upvotes: 1

Related Questions