iphone自动隐藏和显示工具栏和导航条
2011-08-12 17:03
471 查看
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
- 基于JQuery的浮动DIV显示提示信息并自动隐藏
- 滚动条事件,当页面滚动到距顶部一定高度时某DIV自动隐藏和显示
- Win8任务栏自动隐藏后无法显示当鼠标移动到对应的方向不显示
- [Delphi]让窗体感知鼠标的进入与移出并自动隐藏与显示窗口
- jQuery实现根据类型自动显示和隐藏表单
- Iphone隐藏和显示TabBar的方法
- 滚动条变色 隐藏滚动条与双击网页自动滚屏显示代码
- DIV 滚动条的自动显示隐藏
- 让XP下自动隐藏的administrator用户重新显示出来
- Android隐藏以及显示软键盘以及不自动弹出键盘的方法
- datagrid 显示隐藏 工具栏按钮
- Iphone隐藏和显示TabBar的方法