zoukankan      html  css  js  c++  java
  • NavigationController的使用整理

    1.设置NavigationBar的背景色:

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

    2.设置NavigationBar上的标题

      self.navigationItem.title = @"Test";

    3.设置NavigationBar上标题的字体大小和颜色(使用富文本)

      self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor yellowColor],NSForegroundColorAttributeName,[UIFont     systemFontOfSize:50],NSFontAttributeName, nil];

    4.设置NavigationBar背景图:

       [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"1"] forBarMetrics:UIBarMetricsDefault];

    5.隐藏/显示返回键

      在需要隐藏返回键的界面设置:

        self.navigationItem.hidesBackButton = NO;

    6.保留返回箭头,去除返回标题或者改成其他标题

      在push进来的上一级界面中设置:

        UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];

        backItem.title = @"";(不要标题就设置空字符串,其他标题直接写字符串就好了)

        self.navigationItem.backBarButtonItem = backItem;

    7.修改返回键以及标题颜色

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

    8.自定义rightButton

      方法一:
              UIBarButtonItem *button= [[UIBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStyleDone target:self action:@selector(action:)];
              self.navigation.rightBarButtonItem = button;
     
      方法二:
              UIButton *button =[ [UIButton alloc] initWithFrame:CGRectMake(0,0,30,30)];
              [button setImage:[UIImage imageNamed:@“”] forState:UIControlStateNormal];
              [button addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
              UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:button];
              self.navigationItem.rightBarButtonItem = rightItem;
     

      

     

  • 相关阅读:
    Ruby学习笔记5: 动态web app的建立 (2)
    Ruby学习笔记4: 动态web app的建立
    Ruby学习笔记3:Rendering(渲染)和 Redirect(重定向)
    对互联网垂直社交产品的分析
    测试 | 代码覆盖测试工具 | Eclemma
    Jquery | 基础 | 事件的链式写法
    Jquery | 基础 | html()
    Serervlet | 慕课课程实战 | 编写登录逻辑
    Jquery | 外部插入节点
    Jquery | 基础 | .hover()
  • 原文地址:https://www.cnblogs.com/small-octopus/p/4869568.html
Copyright © 2011-2022 走看看