navigationController导航栏总结

1.设置导航栏标题

self.navigationItem.title = @"标题短发短发短发";

2.设置item颜色(返回按钮颜色--并不是标题颜色)

[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

3.设置导航栏背景色

self.navigationController.navigationBar.barTintColor = [UIColor redColor];

4.导航栏背景图片(同时使用方法3 方法3会失效)

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

5.设置导航条标题的字体大小和颜色

self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:12]};

6.导航栏的下边线

[self.navigationController.navigationBar setShadowImage:[UIImage new]];//导航栏的的下边线

7.状态栏的颜色

self.navigationController.navigationBar.barStyle = 1;

8.设置导航条颜色渐变

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];//导航栏的的下边线
UIImageView * viewa = self.navigationController.navigationBar.subviews.firstObject;//导航栏的view
viewa.alpha = 0;
[UIView animateWithDuration:2 animations:^{
    UIImageView * view = self.navigationController.navigationBar.subviews.firstObject;
    view.alpha = 1;
    view.backgroundColor = [UIColor colorWithRed:0.110 green:0.500 blue:1.000 alpha:1.000];
}];

9.设置隐藏导航条(动画)

[self.navigationController setNavigationBarHidden:YES animated:YES];

10.自定义标题View

UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];

title.text = @"title3";

title.textAlignment = NSTextAlignmentCenter;

title.textColor = [UIColor redColor];    

self.navigationItem.titleView = title;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,633评论 25 709
  • 第5章 菜单、按钮及导航 一、下拉菜单 小伙伴们注意,在Bootstrap框架中的下拉菜单组件是一个独立的组件,根...
    凛0_0阅读 10,514评论 0 66
  • 内容抽屉菜单ListViewWebViewSwitchButton按钮点赞按钮进度条TabLayout图标下拉刷新...
    皇小弟阅读 47,003评论 22 665
  • 茆坪村自宋元之际建村,至今有900余年历史,村三面环山,自村北向南一条卵石铺筑的古道穿村而过。也是通往浦江...
    草民0809阅读 3,576评论 0 1
  • Lucene简介 1.什么是Lucene Lucene是一个全文搜索框架,而不是应用产品。因此它并不像http:/...
    ifcoder阅读 1,670评论 0 2