美文网首页
有关导航栏的那些事

有关导航栏的那些事

作者: univer2012 | 来源:发表于2016-03-12 21:40 被阅读101次

1、设置导航栏中间的标题:

self.title=@"popover";

2、设置导航栏的 标题 文字颜色:

[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

3、设置NavigationBar背景颜色

[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:213/255.0 alpha:1.0]];

4、设置UIBarButtonSystemItem 的图标 的颜色:

UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(clickPopoverButton:)];
    barButtonItem.tintColor=[UIColor whiteColor];   //改变UIBarButtonSystemItem的显示颜色
    self.navigationItem.rightBarButtonItem = barButtonItem;

5、设置导航栏标题的 字体颜色、文字阴影、文字大小:

NSShadow *navTitleShadow = [[NSShadow alloc]init];
    navTitleShadow.shadowColor=[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
    navTitleShadow.shadowOffset = CGSizeMake(0, 5);
    
    [self.navigationController.navigationBar setTitleTextAttributes:
  @{NSForegroundColorAttributeName:[UIColor greenColor],/*[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0]*/
    NSShadowAttributeName:navTitleShadow,
    NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0]
    }];

6、使用图片作为导航栏标题。设置了 titleView 后,标题自动会隐藏:

self.title=@"popover";
self.navigationItem.titleView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"qrcode_screen"]];

7、添加多个栏按钮项目:

UIBarButtonItem *shareItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(clickPopoverButton:)];
    UIBarButtonItem *cameraItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(clickPopoverButton:)];
    self.navigationItem.rightBarButtonItems = @[shareItem,cameraItem];  //从右往左

8、自定义后退按钮的文字和颜色(这代码写在push前的控制器里才有效):

UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.backBarButtonItem = backItem;

9、改变 “返回”图标和文字 的颜色
只有执行了下面代码,“返回”图标和文字才会变色,所以是放在执行push前,所有 UIBarButtonSystemItem 的都会变设置的颜色:

self.navigationController.navigationBar.tintColor=[UIColor whiteColor];

10、有导航栏时,获取是在第几页:

self.title = [NSString stringWithFormat:@"第%lu页",(unsigned long)self.navigationController.viewControllers.count];

11、将返回按钮的文字position设置不在屏幕上显示

[[UIBarButtonItem appearance]setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];

12、设置左边按钮和back按钮同时存在:

//在push进去的控制器里设置
self.navigationItem.leftItemsSupplementBackButton = YES;

//13、设置 titleView 的背景颜色:

self.navigationItem.titleView.backgroundColor=[UIColor redColor];

相关文章

  • 有关导航栏的那些事

    1、设置导航栏中间的标题: 2、设置导航栏的 标题 文字颜色: 3、设置NavigationBar背景颜色 4、设...

  • 导航栏那些事

    1.自定义返回按钮的问题 通过设置当前页面的leftBarButtonItem 来替换系统自带的back 按钮,下...

  • bootstrap总结

    1,导航栏:和导航栏有关的class有navbar navbar-inverse navbar-default n...

  • Swift_ios_开发之UINavigationControl

    Swift_ios_开发之UINavigationController的常用属性那些事 1.导航栏是否隐藏 sel...

  • iOS 导航栏上那些事

    一、侧滑返回 侧滑返回手势是从iOS7开始增加的一个返回操作,经历了两年时间估计iPhone用户大部分都已经忽略了...

  • iOS导航栏那些事(LargeTitles)

    在我手机里,【AppStore】这款软件打开的频率虽然不是最高的,但是它是我认为做的最好的。它的亮眼之处在我看来有...

  • 007-rn导航栏组件简单编写

    1:需求解释 1、导航栏是十分常见的一个组件,所有和导航有关的组件都会看到它,但是有时候导航组件自带的导航栏不能满...

  • 导航栏渐变隐现

    页面不显示导航栏,上托一定的距离显示导航栏. 设置导航栏存在且透明: 1.设置导航栏的透明: //导航栏透明 ...

  • iOS11 自定义导航栏衍生的几个问题(高度、间距等)

    本文讨论的问题: 自定义导航栏,导航栏高度; items 与导航栏间的间距; 导航栏的层次结构; 自定义导航栏的一...

  • iOS 状态栏(statusbar)导航栏(navigation

    导航栏透明 导航栏渐变 状态栏字体颜色改变 导航栏隐藏如果导航栏自定义度高,需要完全自己重写,可以隐藏原来的导航栏...

网友评论

      本文标题:有关导航栏的那些事

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