storyboard设计两级TabBarController,第二级Tabbar的位置问题

这个问题已经解决了

但是还是有点迷糊

感谢 willingseal  前辈的 热心指点(http://my.csdn.net/willingyatou/)


 

二级TarBarController布局如上图所示

 

运行效果图如下

 





后面两个图中,我把第二级的TabBarController的位置调整到了上面,代码如下

     CGRect tabBarFrame = [self.tabBar frame];

    tabBarFrame.origin.y = 100;

    [self.tabBar setFrame:tabBarFrame];

这时,虽然tabbar上去了,但是它以前在下面的位置却变成了黑色,

请问怎么把View扩展下来,我通过设置setFrame,好像没有任何效果

这种两级Tabbar应该很普遍吧,主Tabbar在下面,次Tabbar在上面


我一开始直接在ViewController2-1里面viewDidLoad直接设置 self.view的setFrame,没有效果

然后跟踪其中的View的setFrame函数,发现在我setFrame之后,系统还会调用还几次setFrame,直接把我设置的高度冲掉了

height最终打印出来都是362

willingseal 前辈的 热心指点下,我在ViewController2-1的viewDidLoad调用如下代码

UIView *contentView;

    if ( [[self.tabBarController.view.subviewsobjectAtIndex:0]isKindOfClass:[UITabBarclass]] )

        contentView = [self.tabBarController.view.subviewsobjectAtIndex:1];

    else

        contentView = [self.tabBarController.view.subviewsobjectAtIndex:0];

    contentView.frame = CGRectMake(contentView.bounds.origin.x,  contentView.bounds.origin.y,  contentView.bounds.size.width, contentView.bounds.size.height +self.tabBarController.tabBar.frame.size.height);

就可以达到如下的效果了



或者我直接在TabBarViewController1-2的viewDidLoad调用如下代码

    UIView *contentView;

    if ( [[self.view.subviewsobjectAtIndex:0]isKindOfClass:[UITabBarclass]] )

        contentView = [self.view.subviewsobjectAtIndex:1];

    else

        contentView = [self.view.subviewsobjectAtIndex:0];

    contentView.frame = CGRectMake(contentView.bounds.origin.x,  contentView.bounds.origin.y,  contentView.bounds.size.width, contentView.bounds.size.height +self.tabBarController.tabBar.frame.size.height);

也可以达到设置view的height的效果

最后还是要好好感谢willingseal,她非常热心

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值