简体   繁体   中英

Hide/Show NavigationBar & Toolbar on tap

I'm trying to hide my navigationBar and toolbars on tap, similar to the way the Photos application works.

Any pointers would be greatly appreciated.

Thanks!

这也有效:)

[self.navigationController setNavigationBarHidden:YES animated:YES];

Try to animate the y value of UINavigationBar and UIToolBar like this

[UIView beginAnimations: nil context:NULL];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelegate: self];
CGRect rect = self.navigationController.navigationBar.frame;
rect.origin.y = -40;
self.navigationController.navigationBar.frame = rect;
[UIView commitAnimations];

Hope this helps you too.

A.

在iOS 8中,您可以通过以下方式实现:

self.navigationController.hidesBarsOnTap = YES

well you can still use the

[self.navigationController setNavigationBarHidden:YES animated:YES];

and you can stop your view from sliding up when the navigation/ toolbar shows. You can have your navigation/tool bar fade in and out over the view without sliding the view. Try this code it did work for me.

self.wantsFullScreenLayout = YES;

that is if you are currently on the view controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM