¿Es posible ocultarlo con animación?¿Cómo ocultar UITabBarController programmatically?
9
A
Respuesta
22
Una UITabBar hereda de UIView, por lo que puede ocultarla y animarla como lo haría con una UIView estándar.
- (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
También se puede ocultar mediante el inspector de atributos:
pero no con una animación.
+0
Esto es simple y perfecto –
0
Otra solución que utilizo: Métodos llamada cuando se desea ocultar Menú:
//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];
Métodos:
- (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
Cuestiones relacionadas
- 1. Cómo ocultar uitabbarcontroller
- 2. ¿Ocultar UIAlertView programmatically?
- 3. Agregar un controlador TabBar programmatically
- 4. Crear un UISearchDisplayController programmatically
- 5. presentingViewController consiguiendo siempre UITabBarController
- 6. Orientación horizontal para UITabBarController?
- 7. UIModalTransitionStylePartialCurl con UITabBarController
- 8. Cómo cambiar UITabBarController ¿Más título de botón?
- 9. Buscar pestaña activa en UITabBarController
- 10. Cómo mover OpenLayers Vector programmatically?
- 11. Cómo deshabilitar ProgramView maxLines programmatically?
- 12. ¿Cómo obtener Vista Edition programmatically?
- 13. Cómo cerrar Message Dialog programmatically
- 14. ¿Cómo cierro un UISearchDisplayController programmatically?
- 15. Android: ¿Cómo resaltar EditText programmatically?
- 16. ¿Cómo obtener jmap histogram programmatically?
- 17. Android: ¿cómo definir ShapeDrawables programmatically?
- 18. ¿Cómo se configura layout_margin programmatically?
- 19. ¿Cómo crear un ProgressBar programmatically?
- 20. Suprimir másNavigationController en UITabBarController personalizado
- 21. UITabBarController - más de 20 vistas
- 22. UISegmentedControl value changed programmatically
- 23. Establezca NSIndexPath programmatically
- 24. Establecer NSWindow Size programmatically
- 25. Scrolling SWT Table programmatically
- 26. Programmatically modify Ensamblado Encuadernación
- 27. C# create report programmatically
- 28. Ocultar UITabBar?
- 29. SSRS mostrar/ocultar columna Tablix programmatically basado en el parámetro en el archivo rdl
- 30. Compruebe httpErrors errorMode programmatically
pongo una variación de las soluciones propuestas a continuación aquí: http: //stackoverflow.com/questions/4031804/how-to-hide-tab-bar-programatically-and-then-expand-view-to-fit/15855340#15855340 – juggler