美文网首页
IOS 设置导航条navigationbar统一返回按钮

IOS 设置导航条navigationbar统一返回按钮

作者: 越天高 | 来源:发表于2020-05-01 19:31 被阅读0次
    //在自定义的navigationController里面重写push方法
    - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        
        
        if (self.childViewControllers.count>0) //非根控制器
        {
            viewController.hidesBottomBarWhenPushed = YES;
    
            viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem backItemWithImage:[UIImage imageNamed:@"imageName"] hightImage:[UIImage imageNamed:@"imageName"] target:self action:@selector(back) title:@"返回"];
        }
        [super pushViewController:viewController animated:YES];
    }
    
    - (void)back
    {
        [self popViewControllerAnimated:YES];
    }
    

    相关文章

      网友评论

          本文标题:IOS 设置导航条navigationbar统一返回按钮

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