隱藏TabBar的一些方法小結

隱藏TabBar的一些方法小結

 (2012-12-07 10:53:42)
標籤: 

雜談

 

it

分類: ios相關技術
在項目中經常遇到隱藏tabBar,實力很多種方法,可以解決不同情況下問題

1://隱藏tabBar
    WebViewController *webVc = [[WebViewController alloc] init];
    webVc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:webVc animated:YES];
    webVc.hidesBottomBarWhenPushed = NO;
    [webVc release];
2.系統方法    self.hidesBottomBarWhenPushed = YES;

3:自定義tabBar時候,由tabBarController管理的

//隱藏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, iphone5?568:480, view.frame.size.width, view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, iphone5?568-49:480-49, 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, iphone5?568:480)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width,  iphone5?568-49:480-49)];
            }
        }
    }
   
    [UIView commitAnimations];
}
調整子視圖
for (UIView *subView in self.view.subviews) {
        if ([subView isKindOfClass:NSClassFromString(@"UITransitionView")]) {
            //調整子視圖的高度,UITransitionView視圖爲UINavitaionController的根視圖
            //         
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章