我正在我的应用中制作幻灯片。我希望它几乎像Apple的照片应用程序。它几乎完成了一些小问题。我想在屏幕上点击时隐藏导航栏并在再次点击时显示它。但我不知道该怎么做。
答案 0 :(得分:2)
// catch the screen tap and call a method to hide the navigation bar
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleNavBar:)];
[self.view addGestureRecognizer:gesture];
[gesture release];
- (void)toggleNavBar:(UITapGestureRecognizer *)gesture {
BOOL barsHidden = self.navigationController.navigationBar.hidden;
[self.navigationController setNavigationBarHidden:!barsHidden animated:YES];
}
答案 1 :(得分:1)
您想如何隐藏导航栏?在导航栏中点击(这可能非常棘手,如果不是完全不可能的话)或通过其他按钮或通过其他方法?
一般来说,你绝对可以隐藏导航栏。
查看[UINavigationController setNavigationBarHidden: animated:]
(我已将Apple文档链接起来)
答案 2 :(得分:0)
UITapGestureRecognizer * theSingleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self
动作:@selector(handleSingleTapForImage :)]; [inImageView addGestureRecognizer:theSingleTapGesture]; [theSingleTapGesture发布];
在手势方法中显示或隐藏NavigationBar
-(void)handleSingleTapForImage:(UITapGestureRecognizer *)sender {
[self.navigationController setNavigationBarHidden:![self.navigationController isNavigationBarHidden] animated:YES];
}
答案 3 :(得分:0)
使导航半透明
self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent;