objective c - Animate a UINavigationBar's barTintColor -
the app i'm working on changes bartintcolor
of navigation bar when pushing new view controllers. right set colour in destination view controller's viewwillappear:
method, have few issues that.
with way we're doing right now, navigation bar's colour changes abruptly, while rest of bar content animates usual. i'd bar fade between source , destination colour. there way achieve public cocoa touch apis?
you can add animations match timing , animation curve of view controller transition using uiviewcontrollertransitioncoordinator.
a view controller's transitioncoordinator
set after view controller's animation has started (so in viewwillappear
of presented view controller). add animations using animatealongsidetransition:completion:
on transition coordinator.
an example:
[[self transitioncoordinator] animatealongsidetransition:^(id<uiviewcontrollertransitioncoordinatorcontext> context) { self.navigationcontroller.navigationbar.translucent = no; self.navigationcontroller.navigationbar.barstyle = uibarstyleblack; self.navigationcontroller.navigationbar.tintcolor = [uicolor whitecolor]; self.navigationcontroller.navigationbar.bartintcolor = [uicolor redcolor]; } completion:nil];
Comments
Post a Comment