iphone开发如何隐藏各种bar
转载至:http://blog.csdn.net/riveram/article/details/7291142
状态条StatusBar
- [UIApplication sharedApplication].statusBarHidden = YES;
[UIApplication sharedApplication].statusBarHidden = YES;
导航条NavigationBar
- [self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:YES];
TabBar
方法1
- [self.tabBarController.tabBar setHidden:YES];
[self.tabBarController.tabBar setHidden:YES];
这个方法有问题,虽然tabBar被隐藏了,但是那片区域变成了一片空白,无法被其他视图使用。
方法2
对于navigationController+tabBarController的结构,可以在push下一级的childController之前将childController的hidesBottomBarWhenPushed属性设为YES。
比如,可以在childController的初始化方法中做这件事,代码如下:
- // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization.
- self.hidesBottomBarWhenPushed = YES;
- }
- return self;
- }
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
self.hidesBottomBarWhenPushed = YES;
}
return self;
}
方法3
- - (void)makeTabBarHidden:(BOOL)hide
- {
- if ( [self.tabBarController.view.subviews count] < 2 )
- {
- return;
- }
- UIView *contentView;
- if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
- {
- contentView = [self.tabBarController.view.subviews objectAtIndex:1];
- }
- else
- {
- contentView = [self.tabBarController.view.subviews objectAtIndex:0];
- }
- // [UIView beginAnimations:@"TabbarHide" context:nil];
- if ( hide )
- {
- contentView.frame = self.tabBarController.view.bounds;
- }
- else
- {
- contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,
- self.tabBarController.view.bounds.origin.y,
- self.tabBarController.view.bounds.size.width,
- self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
- }
- self.tabBarController.tabBar.hidden = hide;
- // [UIView commitAnimations];
- }
- (void)makeTabBarHidden:(BOOL)hide
{
if ( [self.tabBarController.view.subviews count] < 2 )
{
return;
}
UIView *contentView;
if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
{
contentView = [self.tabBarController.view.subviews objectAtIndex:1];
}
else
{
contentView = [self.tabBarController.view.subviews objectAtIndex:0];
}
// [UIView beginAnimations:@"TabbarHide" context:nil];
if ( hide )
{
contentView.frame = self.tabBarController.view.bounds;
}
else
{
contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,
self.tabBarController.view.bounds.origin.y,
self.tabBarController.view.bounds.size.width,
self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
}
self.tabBarController.tabBar.hidden = hide;
// [UIView commitAnimations];
}
时机
- - (void)viewWillAppear:(BOOL)animated {
- [self setFullScreen:YES];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [self setFullScreen:NO];
- }
- - (void)setFullScreen:(BOOL)fullScreen {
- // 状态条
- [UIApplication sharedApplication].statusBarHidden = fullScreen;
- // 导航条
- [self.navigationController setNavigationBarHidden:fullScreen];
- // tabBar的隐藏通过在初始化方法中设置hidesBottomBarWhenPushed属性来实现。
- }
- (void)viewWillAppear:(BOOL)animated {
[self setFullScreen:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
[self setFullScreen:NO];
}
- (void)setFullScreen:(BOOL)fullScreen {
// 状态条
[UIApplication sharedApplication].statusBarHidden = fullScreen;
// 导航条
[self.navigationController setNavigationBarHidden:fullScreen];
// tabBar的隐藏通过在初始化方法中设置hidesBottomBarWhenPushed属性来实现。
}
iphone开发如何隐藏各种bar相关推荐
- iPhone开发中的一些小技巧
NavBar+TarBar iphone开发 NavBar+TarBar 1 改变NavBar颜色:选中Navigation Bar 的Tint属性.选中颜色. 2 隐藏"back&qu ...
- iphone开发笔记和技巧总结
在iphone程序中实现截屏的一种方法: //导入头文件 #importQuartzCore/QuartzCore.h //将整个self.view大小的图层形式创建一张图片imageUIGrap ...
- [IOS]iphone开发之常用代码:不断更新
1,获取翻转事件,并开启翻转: 只要在viewcontroller的类中加入 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOri ...
- iphone开发之常用代码:不断更新
1,获取翻转事件,并开启翻转: 只要在viewcontroller的类中加入 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOri ...
- 【转载】iphone开发之常用代码:不断更新
转自:http://www.cnblogs.com/iphone520/archive/2012/01/09/2225160.html 1,获取翻转事件,并开启翻转: 只要在viewcontrolle ...
- iPhone开发的一些小技巧
[转载]iPhone开发的一些小技巧 (2011-10-29 20:13:02) 转载原文 标签: 转载 原文地址:iPhone开发的一些小技巧作者:哈哈 一,修改状态栏: 1.加入[[UIAppli ...
- Windows下安装苹果iPhone开发环境xcode图文教程
因为只有在mac系统上才能安装xcode哦~所以我们只有在Windows下先安装虚拟机,然后在虚拟机上安装mac系统. Xcode for Mac(苹果软件开发工具) 官方最新版 http://ww ...
- iPhone开发【一】从HelloWorld開始
转载请注明出处,原文网址:http://blog.csdn.net/m_changgong/article/details/8013553 作者:张燕广 从经典的HelloWorld開始踏入iPhon ...
- 【转】在Windows中搭建iPhone开发环境
很多朋友希望在体验或学习iphone开发,但是iphone开发环境一般需要 安装在mac计算机下mac os中. 这给许多朋友带来了额外成本投入. 网上已经有各种破解方法,在非苹果电脑上安装iphon ...
最新文章
- Web API与JWT认证
- 【log】12/11 checking project:(Laravel)snsTest
- python与人工智能编程-python学习(一)——python与人工智能
- 在游戏中强制关机,不能对关机提示框进行操作
- avalon 框架
- 在 Objective-C 中对 Block 应用 property 时的注意事项
- 穿墙透视真的来了!MIT华人团队超强动作检测模型,小黑屋照样夜视
- 计算营业额python_ARIMA时间序列分析-----Python实例(一周销售营业额预测)
- linux 隐藏显示终端光标
- mouseclick
- 什么是WAP?wap技术简介(转)
- 高等数学教材上册复习
- 2010-2011年美国大学综合排名
- luogu P2184 贪婪大陆
- 论文阅读——Aspect Sentiment Quad Prediction as Paraphrase Generation
- vue3中使用swiper7及autoplay无效问题
- linux的dve界面如何debug,VCS课时3:使用DVE进行Debug
- VIO--后端优化实践(坑)
- 队测 逆序对 permut
- 成功解决问题h5py\h5r.pyx, line 145, in init h5py.h5r AttributeError: type object 'h5py.h5r.Reference' ha