2013/06/07

[Objective-C][iOS]UITabBarを動的に表示・非表示にする

もともと表示されていたUITabBarを非表示にして表示領域を増やす方法はあるのだろうか?

Hide UITabBarController/UITabBar with animation. 」を参考にすると、アニメーションをさせない場合は、下のようにすればいいことがわかる。

//UITabBarController
-(void)showTabBar:(BOOL)isShow{
    CGFloat appHeight = [UIScreen mainScreen].bounds.size.height;

    for(UIView *view in self.view.subviews){
        CGRect viewRect = view.frame;
        CGFloat resetVal = (isShow)? (appHeight - 49) : appHeight;
        if([view isKindOfClass:[UITabBar class]]){
            viewRect.origin.y = resetVal;
        }else{
            viewRect.size.height = resetVal;
        }
        view.frame = viewRect;
    }

}
これで非表示・表示も困ることはありません。

0 コメント:

コメントを投稿