关闭

tabBarController 的隐藏问题

539人阅读 评论(0) 收藏 举报

- (void)hideTabbar:(BOOL)hidden {

    

//  CGRect windowFrame = iPhone5 ? CGRectMake(0.0f, 0.0f, 320.0f, 568.0f) : CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);

   CGRect windowFrame=[[UIScreenmainScreen]bounds ];

//     CGRect windowFrame = CGRectMake(0.0f, 0.0f, 768.0f, 1024.0f);

   float windowHeight = windowFrame.size.height;

   if(hidden) {

       CGRect newFrame = windowFrame;

        newFrame.size.height -=navHeight + statusBarHeight;

       self.view.frame = newFrame;

    }

   else {

       CGRect newFrame = windowFrame;

        newFrame.size.height -=tabBarHeight + navHeight +statusBarHeight;

       self.view.frame = newFrame;

    }

    viewWidth =self.view.frame.size.width;

    viewHeight =self.view.frame.size.height;

   

    

    [UIViewbeginAnimations:nilcontext:NULL];

    [UIViewsetAnimationDuration:0];

   //这个位子给大家注视一下, 获取self.tabBarC中的UItabBar在对其进行隐藏操作

    for(UIView *viewin self.tabBarController.view.subviews){

        

       if([view isKindOfClass:[UITabBar class]]){  

           if (hidden) {

                [viewsetFrame:CGRectMake(view.frame.origin.x, windowHeight, view.frame.size.width, view.frame.size.height)];

            }else {

                [viewsetFrame:CGRectMake(view.frame.origin.x, windowHeight -tabBarHeight, view.frame.size.width, view.frame.size.height)];

            }

        }else{   

           if (hidden) {

                [viewsetFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, windowHeight)];

            }else {

                [viewsetFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, windowHeight -tabBarHeight)];

            }

        }

    }

    [UIViewcommitAnimations];

}

感谢 www.fanmoney.cn站长的支持。 又效果的话bu要忘记了答谢我们的站长的哦 。 进站多关照关照
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:59845次
    • 积分:1250
    • 等级:
    • 排名:千里之外
    • 原创:69篇
    • 转载:2篇
    • 译文:0篇
    • 评论:1条
    最新评论