Czy można go ukryć za pomocą animacji?Jak programowo ukryć program UITabBarController?
9
A
Odpowiedz
22
UITabBar dziedziczy z UIView, dzięki czemu można go ukryć i animować tak, jak przy standardowym UIView.
- (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
Można również ukryć za pomocą Inspektora atrybuty:
ale nie z animacją.
+0
To jest proste i doskonałe –
0
Innym rozwiązaniem używam: Metody połączenia Gdy chcesz ukryć menu:
//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];
metod:
- (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
Powiązane problemy
- 1. Jak programowo ukryć ikony pulpitu?
- 2. jak ukryć klawiaturę programowo w iphone
- 3. Storyboard - UITabBarController
- 4. Twórz program UIWebView programowo
- 5. Anuluj program UIAlertView programowo
- 6. Utwórz program ListView programowo
- 7. Utwórz program TableLayout programowo
- 8. Program Otwarte zdjęcia programowo
- 9. Program ViewPager programowo przewijający
- 10. Jak programowo ponownie uruchomić program Finder?
- 11. Jak prowadzić program Ansible programowo i współbieżnie?
- 12. Jak ustawić program CacheMode na elemencie programowo?
- 13. Spring Mobile: jak programowo dodać program DeviceWebArgumentResolver?
- 14. Jak mogę programowo wysłać program UILongPressGesture?
- 15. Otwórz program DateTimePicker C# programowo
- 16. Programowo pobierać program User-Agent
- 17. Program Swift dodaje ograniczenie programowo
- 18. Program dropzone.js programowo nie działa
- 19. Utwórz program Visual Studio programowo
- 20. jak ukryć klawiaturę w jquery mobile programowo pod fokusem()
- 21. Jak programowo ukryć pasek stanu w iOS 8
- 22. Jak sprawić, aby kontrolery UITabBarController ładowały się leniwie?
- 23. Czy można zmienić program Scala REPL programowo?
- 24. Android - Ustaw program Layout_Gravity programowo dla LinearLayout
- 25. Wykonuj programowo program bez połączenia z przyciskiem?
- 26. android: wybierz domyślnie program uruchamiający programowo
- 27. Jak ustawić wybraną zakładkę w UITabBarController przy użyciu StoryBoard?
- 28. Kiedy "programowo" tworzenia UINavigationController i UITabBarController, w jaki sposób rozwiązać swoje funkcje (jak viewWillAppear?)
- 29. Jak mogę programowo ustawić wybraną zakładkę UITabBarController, jednocześnie uruchamiając shouldSelectViewController w UITabBarControllerDelegate
- 30. Pobierz program z Google Play programowo
kładę wariację na temat proponowanych poniżej tu rozwiązań: http: //stackoverflow.com/questions/4031804/how-to-hide-tab-bar-programically-and-then-expand-view-to-fit/15855340#15855340 – juggler