zoukankan      html  css  js  c++  java
  • iOS导航栏状态栏相关

    状态栏设置颜色没用:

    1. 在UIViewController里的viewWillApper或viewDidAppear里面加入[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]
    2. 去info.plist文件里面设置View controller–based status bar appearance 为NO

    1. [[UINavigationBar appearance]  setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    2. [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];

    或者 

        self.navigationController.navigationBar.clipsToBounds = YES;

     
     

    在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法。

    方法一:(自定义视图的方法,一般人也会采用这样的方式)

    就是在导航向上添加一个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:19],

    NSForegroundColorAttributeName:[UIColor redColor]}];

    方式二相对于方式一而言更加简单方便

     
  • 相关阅读:
    HBase权威指南
    Mapreduce编程
    Hive内部表和外部表的区别
    Android Volley全然解析(四),带你从源代码的角度理解Volley
    codeforces 448CPainting Fence
    2.maven 安装配置
    cocos2d-x 3.0正式版创建project笔记
    C. DZY Loves Sequences
    spring 基础回想 tips01
    spring 配置属性细节
  • 原文地址:https://www.cnblogs.com/LynnAIQ/p/5908633.html
Copyright © 2011-2022 走看看