iOS tabbar隱藏之後,隱藏位置不再被佔用
阿新 • • 發佈:2019-01-09
在使用系統提供的方法(1、hidesBottomBarWhenPushed 2、tabBarController.tabBar.hidden)隱藏tabbar之後,tabbar隱藏,他的位置仍然是不能被其他檢視覆蓋的,所以如果要使用tabbar的位置的話,系統方法是行不通的。
下面介紹其他方法
參考資料:http://blog.csdn.net/a6472953/article/details/8363076
方法新增到controller裡面 呼叫就可以
如果是在很多個介面之間跳轉,而且需要隱藏tabbar,可以寫一個父類,子類繼承父類之後,呼叫方法就可以 ,不用每次都重複新增程式碼- (void) hideTabBar:(BOOL) hidden { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0]; for(UIView *view in self.tabBarController.view.subviews) { if([view isKindOfClass:[UITabBar class]]) { if (hidden) { [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)]; } } else { if (hidden) { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)]; } } } [UIView commitAnimations]; }