博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS导航栏状态栏相关
阅读量:7118 次
发布时间:2019-06-28

本文共 1241 字,大约阅读时间需要 4 分钟。

状态栏设置颜色没用:

  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的背景颜色透明,字体什么的设置就很简单了。

 

//自定义标题视图

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 Color]}];

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

 

 

转载于:https://www.cnblogs.com/LynnAIQ/p/5908633.html

你可能感兴趣的文章
Configure swagger with spring boot
查看>>
nginx重定向规则入门
查看>>
初始化参数之memory_target
查看>>
趣题一则:寻找那扇门
查看>>
Oracle AWR报告提取方法
查看>>
好奇:WayOs破解、OEM、修复、打包等工具大全,满足大家的好奇心发下截图
查看>>
How to use kingshard building a MySQL cluster
查看>>
HibernateAnnotation入门实例
查看>>
iOS 基础介绍 1
查看>>
Qt 快捷键
查看>>
SAP HANA创建类型(SAP HANA CREATE TYPE):
查看>>
深入浅出CChart 每日一课——第十六课 实习之旅,百年老店之新锐WTL
查看>>
Signal Handling--ref
查看>>
SkinSharp用法
查看>>
大抚州泡粉
查看>>
【RMQ问题】求数组区间最大值,NYOJ-1185-最大最小值
查看>>
简易实现 TextView单行文本水平触摸滑动效果
查看>>
android调用系统相机拍照并保存在本地
查看>>
Node.js链式回调
查看>>
IOS中延时执行的几种方式的比较
查看>>