设为首页 加入收藏

TOP

设置全局导航栏颜色,标题大小和UIBarButtonItem字体大小
2017-10-10 12:14:16 】 浏览:3151
Tags:设置 全局 导航 颜色 标题 小和 UIBarButtonItem 字体 大小

 

  设置全局导航栏颜色,标题大小和UIBarButtonItem字体大小

在appdelegate里面设置

swift:

UINavigationBar.appearance().barTintColor = UIColor.init(red: 47, green: 48, blue: 52)

        UINavigationBar.appearance().tintColor = UIColor.whiteColor()

        UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: UIFont.boldSystemFontOfSize(18),NSForegroundColorAttributeName: UIColor.whiteColor()]

        UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(15),NSForegroundColorAttributeName: UIColor.whiteColor()], forState: UIControlState.Normal)

 

oc:

#pragma mark -  设置全局返回按钮,无文字

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)

                                                         forBarMetrics:UIBarMetricsDefault];

 

如果需要设置导航栏颜色,使barItem颜色也被渲染了,可以这样设置(就可以保证barItem里面图片的颜色不被渲染了)

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage: [[UIImage imageNamed: @"xiaoxi_icon"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal] style: UIBarButtonItemStylePlain target: self action: @selector(a)];

 

 

如果导航栏与view出现了空隙。需要把系统默认设置空隙值关掉

#pragma 设置控制器,出现默认知道空隙

//    self.automaticallyAdjustsScrollViewInsets = NO;

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇[iOS笔记]Swift中的Optional类型 下一篇Studying-Swift :Day01

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目