• 自定义导航条上的标题文字的大小以及颜色


    在做项目开发时,有的时候回自定义导航条视图,常见的是设置标题文字的大小颜色、左侧以及右侧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]}];//设置导航条标题文字的颜色

  • 相关阅读:
    mssql 循环的写法,备用
    用了十几年的windows记录下我不知道的几个快捷键
    折腾了下java下webservice,折腾了大半天,居然是eclipse的版本不对
    连接Linux 下mysql 慢的问题,解决之
    解决windows7蓝屏的方法
    MySQL錯誤:Value '00000000' can not be represented as java.sql.Date解決方法[转]
    jdbc连接三种数据库的连接语句写法(备查)
    遇到一个json解析的错误,费了好大的劲,最后发现是少了一个包
    【转】The reference to entity "characterEncoding" must end with the ';' delimiter
    synaptics 插入USB鼠标禁用,网上
  • 原文地址:https://www.cnblogs.com/liu-lang/p/5725860.html
Copyright © 2020-2023  润新知