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;
     

      

     

  • 相关阅读:
    ajax traditional
    阿里云OSS NET SDK 引用示范程序
    js对象的两种写法
    BZOJ NOIP提高组十连测第一场
    ikbc 时光机 F87 Ctrl 失灵 解决办法
    【读书笔记】阅读的危险
    51nod 1118 机器人走方格 解题思路:动态规划 & 1119 机器人走方格 V2 解题思路:根据杨辉三角转化问题为组合数和求逆元问题
    【算法】求逆元模板
    【复习资料】软件工程之快速原型模型
    VirtualBox安装linux mint教程
  • 原文地址:https://www.cnblogs.com/small-octopus/p/4869568.html
Copyright © 2011-2022 走看看