Objective C - Hiding UINavigationController & UITabBarController with animation
I'm working on an app that has a UITabBarController at the bottom and UINavigationController at the top of the screen.
One of the section that can be accessed through UITabBarController is a "photo gallery" section, where I can view the photo in full screen.
I'm able to hide them WITHOUT animation using the following code
self.navigationController.navigationBarHidden = YES;
[self.tabBarController.tabBar setHidden:TRUE];
How can I hide UINavigationController & UITabBarController wit开发者_运维技巧h a little fade animation just when I want to view the photo in full screen? (Just like how the Facebook app hides them when you want to view the photo full screen)
Or is there an even better approach than what I'm doing as per the code snippet?
Thank you,
TeeJust make your own animation. You can use the following code...
For the UINavigationController:
[UINavigationBar beginAnimations:@"NavBarFade" context:nil];
self.navigationController.navigationBar.alpha = 1;
[self.navigationController setNavigationBarHidden:YES animated:NO]; //Animated must be NO!
[UINavigationBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UINavigationBar setAnimationDuration:1.5];
self.navigationController.navigationBar.alpha = 0;
[UINavigationBar commitAnimations];
For the UITabBarController:
[UITabBar beginAnimations:@"TabBarFade" context:nil];
self.tabBarController.tabBar.alpha = 1;
[UITabBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UITabBar setAnimationDuration:1.5];
self.tabBarController.tabBar.alpha = 0;
[UITabBar commitAnimations];
You can also choose a different UIViewAnimationCurve
for different types of fading, or change the duration of the animation by giving the setAnimationDuration
message a different input (it's time in seconds).
Edit: For the "reappearing" fade animation you would simply reverse the alpha values, so that you go from 0 to 1. If you wanna see the code for this just leave me a comment.
精彩评论