你的位置:首页 > 软件开发 > 操作系统 > IOS导航栏颜色渐变与常用属性

IOS导航栏颜色渐变与常用属性

发布时间:2015-10-23 15:58:12
导航栏背景色设置:self.navigationController.navigationBar.barTintColor = [UIColor greenColor];导航栏标题颜色字体大小 NSMutableDictionary *attrs = [NSMu ...
  1. 导航栏背景色设置:

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

  2. 导航栏标题颜色字体大小

        NSMutableDictionary *attrs = [NSMutableDictionary dictionary];

        attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];

        attrs[NSFontAttributeName] = [UIFont systemFontOfSize:17];

        [self.navigationController.navigationBar setTitleTextAttributes:attrs];

  3. 导航栏左右item

     UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStylePlain target:self action:@selector(left)];

      self.navigationItem.leftBarButtonItem = leftItem;

      UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"right" style:UIBarButtonItemStylePlain target:self action:@selector(right)];   

        self.navigationItem.rightBarButtonItem = rightItem;

  4. 导航栏item字体颜色

     self.navigationController.navigationBar.tintColor = [UIColor redColor];如果要不同item不同颜色,那么item要带一个自定义按钮,在设置按钮属性

  5. 当前控制器的下一个控制的返回item去掉文字只保留箭头

        UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(back)];

     self.navigationItem.backBarButtonItem = backItem;

  6. 导航栏透明与导航栏底部分割线,如果有图片高为64的话,直接设置图片就可以了,除此之外还可以用代码,这边的例子全部用代码背景色转图片来设置,先设置整个view的背景色为

     self.view.backgroundColor = [UIColor greenColor];如果透明看到的就是绿色。然后在分别设置

     [self.navigationController.navigationBar setBackgroundImage:[self imageWithBgColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:0]] forBarMetrics:UIBarMetricsDefault];

       [self.navigationController.navigationBar setShadowImage:[self imageWithBgColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:0]]];这样就是透明的了IOS导航栏颜色渐变与常用属性


原标题:IOS导航栏颜色渐变与常用属性

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。