Ist es möglich, es mit Animation zu verstecken?Wie UITabBarController programmgesteuert auszublenden?
9
A
Antwort
22
Eine UITabBar erbt von UIView, so dass Sie sie ausblenden und animieren können, wie Sie es mit einer Standard-UIView tun würden.
- (void) hideTheTabBarWithAnimation:(BOOL) withAnimation {
if (NO == withAnimation) {
[theTabBar setHidden:YES];
} else {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:nil];
[UIView setAnimationDuration:0.75];
[theTabBar setAlpha:0.0];
[UIView commitAnimations];
}
}
20
5
Sie es auch verstecken können die Attribute Inspektor:
aber nicht mit einer Animation.
+0
Dies ist einfach und perfekt –
0
Eine andere Lösung Ich benutze: Anrufmethoden Wenn Sie wollen Menü ausblenden:
//Show Tab Bar
[self showTabBar:self.tabBarController];
//If You Want to Hide/Show Navigation Bar Also
[self.navigationController setNavigationBarHidden: NO animated:YES];
//Hide Tab Bar
[self hideTabBar:self.tabBarController];
//If You Want to Hide/Show Navigation Bar Also
[self.navigationController setNavigationBarHidden: YES animated:YES];
Methoden:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width,
view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width,
view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
1
-(void)hideTabBar
{ UITabBarController * tabbarcontroller= appDelegate.tabBarVC;
if (tabbarcontroller.tabBar.isHidden)
{
return;
}
tabbarcontroller.tabBar.hidden=YES;
CGRect frm=tabbarcontroller.view.frame;
frm.size.height += tabbarcontroller.tabBar.frame.size.height;
tabbarcontroller.view.frame=frm;
}
-(void)showTabBar
{ UITabBarController * tabbarcontroller=appDelegate.tabBarVC;
if (!tabbarcontroller.tabBar.isHidden)
{
return;
}
CGRect frm=tabbarcontroller.view.frame;
frm.size.height -= tabbarcontroller.tabBar.frame.size.height;
tabbarcontroller.view.frame=frm;
tabbarcontroller.tabBar.hidden=NO;
}
here appDelegate is = (AppDelegate *) [[UIApplication sharedApplication] delegate]
tabBarVc is UITabBarController *tabBarVC defined as property in app delegate
hope this helps
Verwandte Themen
- 1. wie programmatisch eine Schaltfläche auszublenden
- 2. Wählen Sie ein Tab-Leiste-Element programmgesteuert (nicht mit UITabBarController)
- 3. Three.js wie Audio auszublenden?
- 4. UITabbarController Problem
- 5. UITabBarController UINavigationController
- 6. Wie UITabbarController UIViewController in iOs
- 7. Kreisspur auf Leinwand auszublenden
- 8. Wie Passwörter in der Jenkins-Konsolenausgabe auszublenden?
- 9. AngularJS - wie Richtlinie auszulösen auf auszublenden Elemente
- 10. UITabBarController und Storyboards
- 11. UITabBarController mit UINavigationController
- 12. UITabBarController UINavigationController Design-Tipp
- 13. presentingViewController bekomme immer UITabBarController
- 14. UITabBarController mit UITableView
- 15. UITabBarController moreNavigationController und Navigationsleiste
- 16. Wie Sie UIImagePickerController in UITabbarController einfügen
- 17. Wie bette ich UITabBarController in UINavigationController ein?
- 18. Wie setze ich UITabBarController auf View?
- 19. Wie UITabBarController zu haben ist tabBarSelection
- 20. Wie kann UITabBarController View Controller träge laden?
- 21. Um nur backgronud Farbe auszublenden
- 22. Hide UIAlertView programmgesteuert?
- 23. mehr in UITabBarController Customizing - "konfigurieren"
- 24. Benutzerdefinierter UITabBarController mit verschiedenen Objektfarben
- 25. UITabBarController tabBar setItemWidth funktioniert nicht
- 26. Hinzufügen einer UINavigationBar zu UITabBarController
- 27. UITabBarController Position und Größe anzeigen
- 28. Wechseln zwischen UITabBarController und UINavigationController
- 29. Transition Delegate für UITabBarController Animation
- 30. UIViewController in UITabBarController ist schwarz
ich auf die Lösungen eine Variante setzen unten hier vorgeschlagen: http: //stackoverflow.com/questions/4031804/how-to-hide-tab-bar-programatically-and-then-expand-view-to-fit/15855340#15855340 – juggler