美文网首页iOS Developer首页推荐iOS 开发
解决导航栏按钮文字的渲染方法

解决导航栏按钮文字的渲染方法

作者: 打电话记错号码的人 | 来源:发表于2016-09-19 17:15 被阅读204次

    作品链接:
    http://www.jianshu.com/users/1e0f5e6f73f6/top_articles

    1.通过setTintColor设置导航条文字的颜色

    [bar setTintColor:[UIColor whiteColor]];
    

    2.通过图片设置,在Images.xcassets里设置图片为非default

    • 代码
    // self -> 导航控制器
    - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        if (self.viewControllers.count != 0) { // 非跟控制器 隐藏底部导航条
            viewController.hidesBottomBarWhenPushed = YES;
            
            // 设置导航条左边按钮的内容,把系统的返回按钮给覆盖,导航控制器的滑动返回功能就木有啦
            viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"导航栏按钮的图片"] style:UIBarButtonItemStyleBordered target:self action:@selector(back)];
        }
        // 返回
        [super pushViewController:viewController animated:animated];
    }
    
    - (void)back
    { 
        [self popViewControllerAnimated:YES];
    }
    
    

    相关文章

      网友评论

        本文标题:解决导航栏按钮文字的渲染方法

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