iOS push&pop导航栏颜色渐变(UIViewControllerTransitionCoordinator)

核心方法就是UIViewControllerTransitionCoordinator(控制器过渡协调器)

只需要在各个控制器中的viewWillAppear方法中添加以下代码即可:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.barTintColor = [UIColor dd_hexStringToColor:@"EA1861"];

    [self.transitionCoordinator animateAlongsideTransition:^(id  _Nonnull context) {
        self.navigationController.navigationBar.barTintColor = [UIColor dd_hexStringToColor:@"EA1861"];  
    } completion:^(id  _Nonnull context) {
    }];
}

你可能感兴趣的:(iOS push&pop导航栏颜色渐变(UIViewControllerTransitionCoordinator))