iphone自动隐藏和显示工具栏和导航条
2011-06-12 10:48
513 查看
iphone里如何实现像图片浏览那样的自动隐藏和导航条和工具栏呢?其实很简单,只需要设置toolbar和navigationBar的显示和隐藏属性就可以了。
效果图如下
未隐藏的效果图
隐藏后的效果图
具体实现代码如下
首先在viewDidLoad里设置toolBarHidden = NO, 默认是YES(隐藏的),为了让toolbar显示,需要设置为NO(不隐藏)。
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"隐藏导航栏";
// self.toolbarItems
self.navigationController.toolbar.barStyle = self.toolBar.barStyle;
self.navigationController.toolbarHidden = NO;
[self.navigationController.toolbar setTranslucent:YES];
self.toolbarItems = [[[NSMutableArray alloc] initWithArray:self.toolBar.items] autorelease];
}
在点击中间button的时候的显示和隐藏navigation bar和toolBar
实现代码如下:
- (IBAction)toggleNavigationBar:(id)sender {
//Check the current state of the navigation bar...
BOOL navBarState = [self.navigationController isNavigationBarHidden];
//Set the navigationBarHidden to the opposite of the current state.
[self.navigationController setNavigationBarHidden:!navBarState animated:YES];
[self.navigationController setToolbarHidden:!navBarState animated:YES];
//Change the label on the button.
if (navBarState) {
[button setTitle:@"隐藏 Navigationr and toolbar" forState:UIControlStateNormal];
[button setTitle:@"隐藏 Navigation Bar toolbar" forState:UIControlStateHighlighted];
} else {
[button setTitle:@"显示 Navigation Bar toolbar" forState:UIControlStateNormal];
[button setTitle:@"显示 Navigation Bar toolbar" forState:UIControlStateHighlighted];
}
}
这样的效果有什么用呢,比如我们常见的电子书,点击中间那块区域的时候显示一些设置和导航。
本文链接:http://www.cnblogs.com/likwo/archive/2011/06/12/2078760.htm
转载请注明出处。
参考文档:
http://www.raddonline.com/blogs/geek-journal/iphone-sdk-uinavigationcontroller-hiding-the-navigation-bar http://icodesnip.com/snippet/iphone/iphonesdkuinavigationbar
项目下载
效果图如下
未隐藏的效果图
隐藏后的效果图
具体实现代码如下
首先在viewDidLoad里设置toolBarHidden = NO, 默认是YES(隐藏的),为了让toolbar显示,需要设置为NO(不隐藏)。
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"隐藏导航栏";
// self.toolbarItems
self.navigationController.toolbar.barStyle = self.toolBar.barStyle;
self.navigationController.toolbarHidden = NO;
[self.navigationController.toolbar setTranslucent:YES];
self.toolbarItems = [[[NSMutableArray alloc] initWithArray:self.toolBar.items] autorelease];
}
在点击中间button的时候的显示和隐藏navigation bar和toolBar
实现代码如下:
- (IBAction)toggleNavigationBar:(id)sender {
//Check the current state of the navigation bar...
BOOL navBarState = [self.navigationController isNavigationBarHidden];
//Set the navigationBarHidden to the opposite of the current state.
[self.navigationController setNavigationBarHidden:!navBarState animated:YES];
[self.navigationController setToolbarHidden:!navBarState animated:YES];
//Change the label on the button.
if (navBarState) {
[button setTitle:@"隐藏 Navigationr and toolbar" forState:UIControlStateNormal];
[button setTitle:@"隐藏 Navigation Bar toolbar" forState:UIControlStateHighlighted];
} else {
[button setTitle:@"显示 Navigation Bar toolbar" forState:UIControlStateNormal];
[button setTitle:@"显示 Navigation Bar toolbar" forState:UIControlStateHighlighted];
}
}
这样的效果有什么用呢,比如我们常见的电子书,点击中间那块区域的时候显示一些设置和导航。
本文链接:http://www.cnblogs.com/likwo/archive/2011/06/12/2078760.htm
转载请注明出处。
参考文档:
http://www.raddonline.com/blogs/geek-journal/iphone-sdk-uinavigationcontroller-hiding-the-navigation-bar http://icodesnip.com/snippet/iphone/iphonesdkuinavigationbar
项目下载
相关文章推荐
- iphone自动隐藏和显示工具栏和导航条
- iphone自动隐藏和显示工具栏和导航条
- iphone自动隐藏和显示工具栏和导航条
- iphone里如何实现像图片浏览那样的自动隐藏和导航条和工具栏
- mdichildform子窗体显示如何自动隐藏主窗体的工具栏???
- 滚动时自动显示与隐藏导航条定制
- jquery 导航条 显示和自动隐藏div
- 小记 ScrollView 隐藏 里面空间填充后再次设置显示,界面会自动往上滑动
- 点击自动显示/隐藏DIV代码。(简单实用)
- echarts中横坐标值显示不全(自动隐藏)解决方案
- 文本框文本域提示自动显示隐藏jQuery小插件
- 用jQuery实现一些导航条切换,显示隐藏
- 基于JQuery的浮动DIV显示提示信息并自动隐藏
- 如何实现:GridView 控件中显示的文本不自动换行,隐藏超出宽度部分wj-wangjun
- 神奇的listView实现自动显示隐藏布局Android代码
- Android ListView自动显示隐藏布局的实现方法
- ASP.NET 提示框显示及自动隐藏(jquery+后台代码)
- jQuery实现根据类型自动显示和隐藏表单
- 基于JQuery的浮动DIV显示提示信息并自动隐藏
- WPF自动隐藏的消息框(鼠标放上去将一直显示,移开动画继续),提供normal和error两种边框。