zoukankan      html  css  js  c++  java
  • 自定义导航条上的标题文字的大小以及颜色

    在做项目开发时,有的时候回自定义导航条视图,常见的是设置标题文字的大小颜色、左侧以及右侧navgationItem。

    在做自定义导航视图的时候 ,导航项都可以用自定义视图的形式自定义。

    自定义导航条标题的时候有两种方法:一是,采用自定义视图的方式;二是,采用系统的方法。

    • 采用自定义视图view的方式

             就是在导航向上添加一个titleView,可以使用一个label,再设置label的背景颜色透明,字体什么的设置就很简单了。                                                                    

              UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];                    

              titleLabel.backgroundColor = [UIColor grayColor];                                                                                                                              

              titleLabel.font = [UIFont boldSystemFontOfSize:20];

              titleLabel.textColor = [UIColor  greencolor];  

              titleLabel.textAlignment = NSTextAlignmentCenter;                                                                                                                                                                                                           

              titleLabel.text = @"新闻";                                                                                                                                    

              self.navigationItem.titleView = titleLabel;

    • 在默认显示的标题中直接修改文件的大小和颜色也是可以的

          //设置标题的大小以及标题文字的颜色

                 [self.navigationController.navigationBar setTitleTextAttributes:

                       @{NSFontAttributeName:[UIFont systemFontOfSize:20], //设置导航条标题文字的大小

                        NSForegroundColorAttributeName:[UIColor whiteColor]}];//设置导航条标题文字的颜色

  • 相关阅读:
    一.创建型模式 Factory
    Tcp/Ip I/O函数
    Tcp/Ip协议理解_简单实例
    Tcp/Ip协议理解_3
    Tcp/Ip协议理解_2
    Tcp/Ip协议理解_1
    abp+angular+bootstrap-table的使用
    Abp mvc angular 添加视图
    Abp添加菜单
    JS 获取一串路径中的文件名称
  • 原文地址:https://www.cnblogs.com/liu-lang/p/5725860.html
Copyright © 2011-2022 走看看