核心方法就是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) {
}];
}