iOS push&pop导航栏颜色渐变(UIViewContro
2017-06-13 本文已影响0人
师从小马哥
核心方法就是UIViewControllerTransitionCoordinator(控制器过渡协调器)
只需要在各个控制器中的viewWillAppear方法中添加以下代码即可:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.barTintColor = [UIColor dd_hexStringToColor:@"EA1861"];
[self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
self.navigationController.navigationBar.barTintColor = [UIColor dd_hexStringToColor:@"EA1861"];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
}];
}