美文网首页
iOS 替换NavigationViewController返回

iOS 替换NavigationViewController返回

作者: JasonEVA | 来源:发表于2016-04-27 09:32 被阅读401次

在工程的BaseNavigationViewController中添加如下代码:

 - (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.navigationBar setBarTintColor:[UIColor mainThemeColor]];
    self.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:18]}];
}

 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{   //拦截所有push进来的子控制器
    if(self.viewControllers.count > 0)
    {
        viewController.hidesBottomBarWhenPushed = YES;
        
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageNamed:@"back.png" targe:self action:@selector(backUp)];
        
    }
    [super pushViewController:viewController animated:animated];
    
}

 - (void)backUp
{
    [self popViewControllerAnimated:YES];
}

相关文章

网友评论

      本文标题:iOS 替换NavigationViewController返回

      本文链接:https://www.haomeiwen.com/subject/mvlcrttx.html