I have a view with lots of text in it, so I want to allow the user to hide the statusBar + navigationBar with one click. I really like the hiding style in the Pictures app, where the statusBar and navigationBar are hiding (not sliding, just disappearing), with some Duration animation, so I tried to do something like this. Here is what I do in touchdidBegan methods:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent]; [UIView setAnimationDuration:0.5]; [UIView beginAnimations:@"" context:nil]; [[UIApplication sharedApplication] setStatusBarHidden:!([UIApplication sharedApplication].statusBarHidden) withAnimation:UIStatusBarAnimationNone]; [self.navigationController setNavigationBarHidden:(!self.navigationController.navigationBarHidden) animated:NO]; [UIView commitAnimations]; self.navigationController.navigationBar.translucent = !self.navigationController.navigationBar.translucent;
But this does not hide the stripes at the same time. This makes them slide down. It has the same effect as this version of the method above:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent]; // deleted UIView animation, changed animation type to "slide" [[UIApplication sharedApplication] setStatusBarHidden:!([UIApplication sharedApplication].statusBarHidden) withAnimation:UIStatusBarAnimationSlide]; // enabled animation for navBar [self.navigationController setNavigationBarHidden:(!self.navigationController.navigationBarHidden) animated:YES]; self.navigationController.navigationBar.translucent = !self.navigationController.navigationBar.translucent; // this is needed to make bars appear on top of my view. }
If I get rid of the UIView animation and hide the bars without animation, they will hide and appear at the same time, but TOO fast. Maybe I'll go in the wrong direction. I would be grateful if someone would help me with this.
Edit: got a job
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
source share