导航栏的坑 (导航透明/导航除线/titleIView)
2024-10-18 18:18:40
//以下四个条件缺一不可 /.必须是半透明状态
self.navigationBar.translucent = YES;
//2.导航栏背景图片为空图片 (不可以设置backgroundColor或者barTintColor, 没有效果的)
[self.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics: UIBarMetricsDefault];
//3.阴影图片为空图片 (不可以设置为nil,没用的)
[self.navigationBar setShadowImage:[[UIImage alloc] init]]; //其实到导航栏才44px, 但是backgroundView有64px
self.navigationBar.layer.masksToBounds = YES;
导航除线
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.shadowImage = [UIImage new];
UIImage *img = [UIImage imageWithColor:[UIColor greenColor] size:CGSizeMake(, )];
//必须设置一张图片而不是设置背景颜色
[self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
3.设置设置titleView时, titleView的宽度和高度无法自由设置
设置搜索案例
如果已经设置了默认返回的图标, 你会发现设置titleview时, 你的titleview左边会空出一块
UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(, , , )];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:tf];
self.navigationItem.leftBarButtonItem = item;
最新文章
- 如何用fir.im 命令行工具 打包上传
- C#继承里的【就近原则】
- <;<; CocoaPods安装和使用教程 >;>;github code4app以及cocoachina 苹果官方文档
- 实例:图形绘制[OpenCV 笔记15]
- spring 学习 AOP和IOC
- grunt中常见的插件
- python 标准库 -- configparser
- spring mvc获取绝对路径的几种方法
- TCP协议中三次握手
- Pytorch
- [Swift]LeetCode537. 复数乘法 | Complex Number Multiplication
- pythonのdjango
- Slimming Plan
- HDFS集群优化篇
- springboot配置server相关配置&;整合模板引擎Freemarker、thymeleaf&;thymeleaf基本用法&;thymeleaf 获取项目路径 contextPath 与取session中信息
- Springboot学习04-默认错误页面加载机制源码分析
- 关于OpenJDK和Orcale JDK区别
- Twitter Bootstrap3小结
- .net MVC 登陆模块后台代码
- readonly const
热门文章
- Yocto开发笔记之《快速入门,环境搭建 &; 编译》(QQ交流群:519230208)
- JavaWeb学习笔记——Web开发模式:Mode I和Mode II
- ubuntu下Eclipse下添加GBK编码
- Jquerymobile 简单安装
- Unity 播放 视频
- Django笔记-常见错误整理
- valuestack,stackContext,ActionContext.之间的关系以及如何存取数值的
- js变量在属性里的写法 常用mark 多个DL遍历添加一个父级DIV
- Kafka【第一篇】Kafka集群搭建
- Python开发【第十八篇】:MySQL(二)