How to Hide Tab Bar Controller?

后端 未结 10 1672
猫巷女王i
猫巷女王i 2020-12-05 00:43

How to Hide Tab Bar Controller ? I want to hide the Tab Bar controller with double tap on UIImageView.

10条回答
  •  独厮守ぢ
    2020-12-05 01:18

    Use the code below to hide/show tab bar controller in animated style.
    hiddenTabBar is a BOOL variable.

    - (void) hidetabbar {
    
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.0];
    
        for(UIView *view in objtabbar.view.subviews)
        {
    
            if([view isKindOfClass:[UITabBar class]])
            {
    
                if (hiddenTabBar) {
                    [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
                } else {
                    [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
                }
            } else {
                if (hiddenTabBar) {
                    [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
                } else {
                    [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
                }
    
            }
        }
    
        [UIView commitAnimations];
    
        hiddenTabBar = !hiddenTabBar;
    }
    

提交回复
热议问题