UINavigationBar 总结
一、某个 ViewController 出现隐藏 NavigationBar
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
二、调整 NavigationBar 高度
1、介绍
1) 默认是 44 个像素点。
2、使用
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. self.title = @"AAAAA"; UIBarButtonItem* leftBarButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Action_Moments.png"]
style:UIBarButtonItemStyleBordered target:self
action:@selector(onclickBackBarButton)];
self.navigationItem.leftBarButtonItem = leftBarButton;
} - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; CGRect rect = self.navigationController.navigationBar.frame;
rect.size.height = 100.0f;
self.navigationController.navigationBar.frame = rect; [self.navigationController.navigationBar setTitleVerticalPositionAdjustment:-40.0f forBarMetrics:UIBarMetricsDefault]; // [self.navigationItem.backBarButtonItem setBackgroundVerticalPositionAdjustment:-40.0f forBarMetrics:UIBarMetricsDefault]; // 对系统自带的 backBarButton 不起作用 [self.navigationItem.leftBarButtonItem setBackgroundVerticalPositionAdjustment:-40.0f forBarMetrics:UIBarMetricsDefault];
} - (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated]; CGRect rect = self.navigationController.navigationBar.frame;
rect.size.height = 44.0f;
self.navigationController.navigationBar.frame = rect;
}

注意:
1) 如果使用系统默认的 backBarButton 是不能调整高度的。
2) 只有自定的 barButtonItem,而且使用以下初始化,才可以调整其高度。
- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
UINavigationBar 总结的更多相关文章
- iOS阶段学习第31天笔记(UINavigationBar介绍)
iOS学习(UI)知识点整理 一.UINavigationBar 的介绍 1)概念:UINavigationBar 是用于定义导航栏按钮的一个类对象 2)在使用UINavigationBar之前必须先 ...
- UINavigationItem UINavigationBar 关系分析
目录 1.关系分析 2.关系综述 3.概念点 4.疑问 1.关系分析 UIBarItem-> UIBarButtonItem -> UINavigationItem 1.1 UIBarIt ...
- UINavigationItem UINavigationBar 关系分析[转]
http://blog.csdn.net/luoyeffcs/article/details/16106707 目录 1.关系分析 2.关系综述 3.概念点 4.疑问 1.关系分析 UIBarItem ...
- iOS开发备忘录:自定义UINavigationBar背景图片和Back按钮
iOS项目,根据设计图,有时需要自定义UIView的UINavigationBar的背景.可以切出来一张1像素左右的背景图片,来充当UINavigationBar的背景. 可以利用Navigation ...
- UITabBar,UINavigationBar的布局和隐藏问题
---恢复内容开始--- 1. 前言 UITabBar,UINavigationBar非常的好用,但是毕竟是系统自带的,不受自己完全掌握,对于布局和隐藏会有一些问题,现在就来谈谈我的想法和一些问题. ...
- UINavigationBar 和 UINavigationItem的属性设置
#import "RootViewController.h" @interface RootViewController () @end @implementation RootV ...
- IOS 入门开发之创建标题栏UINavigationBar的使用(二)
IOS 入门开发之创建标题栏UINavigationBar的使用 http://xys289187120.blog.51cto.com/3361352/685746 IOS 开发有关界面的东西 ...
- iOS7中如何去除UINavigationbar下边的那条黑线
做项目过程中遇到要去掉导航栏下面的一条黑线,从网上找到的一个方法 默认UINavigationbar样式 准备用于替换的背景 替换后的效果 if ([self.navigationController ...
- ios7 自定义UINavigationBar UIBarButtonItem 10px的偏移纠正
为UINavigationBar 写一个分类.UINavigationItem+correct_offset.h 转载 http://www.colabug.com/thread-1112420-1 ...
- iOS 开发 中级:UIToolbar,UINavigationBar,UITabBar,UIBarButtonItem,UITabBarItem自定义方法总结
原文: http://blog.csdn.net/songrotek/article/details/8692866?utm_source=tuicool 对于UIToolbar,UINavigat ...
随机推荐
- #asp.net core mvc 的视图注入
View injection is the most useful feature introduced in ASP.NET Core. 1.添加一个FruitsService public cla ...
- Redis 安装为Window服务
参考: http://www.cnblogs.com/zhoub/p/3841222.html 关键命令 redis-server.exe –service-install conf/redis.co ...
- Date 对象转换——toString、toTimeString、toDateString、toUTCString、toLocaleString()、toLocaleTimeString()、toLocaleDateString()
JavaScript toString() 方法 JavaScript Date 对象参考手册 定义和用法:toString() 方法可把 Date 对象转换为字符串,并返回结果. 语法:dateOb ...
- CF# Educational Codeforces Round 3 E. Minimum spanning tree for each edge
E. Minimum spanning tree for each edge time limit per test 2 seconds memory limit per test 256 megab ...
- BZOJ4568 : [Scoi2016]幸运数字
树的点分治,每次求出重心后,求出重心到每个点路径上的数的线性基. 对于每个询问,只需要暴力合并两个线性基即可. 时间复杂度$O(60n\log n+60^2q)$. #include<cstdi ...
- 【BZOJ3531】[Sdoi2014]旅行 树链剖分+动态开点线段树
[BZOJ3531][Sdoi2014]旅行 Description S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天 ...
- wamp 2.5 开放访问权限和设置虚拟域名
开放访问权限 D:\wamp\bin\apache\apache2.4.9\conf 里的 httpd.conf 搜索www 把 Require local 改为 Require all gra ...
- 最近发现docker感觉不错
最近发现docker感觉不错,接下来开始学习docker方面的技术.lxc也可以学学. storm,kafka也要熟悉起来.
- List<子类>转List<父类>遇到的问题
public class A{ } public class B extends A { } 一个方法中如下定义: public List<A> funName(List<A> ...
- The design of a distributed variant of Plato framework to support collaborated editing
A first thought system architecture (pulling mode) is one that the server doesn't keep client inform ...