开发者社区> 问答> 正文

iOS 7UITabbarController 自定义tabbar高度与内容view高度

如题,iOS 7怎样实现内容view的高度调整?沿用iOS 6的方法是不行的

展开
收起
a123456678 2016-07-20 17:09:13 5356 0
1 条回答
写回答
取消 提交回答
  • 请问你是想自定义 tabbar 的高度还是想调整 content view 的高度? 你可以使用下面的方法来打印出 UITabBarController 的 View 的子视图信息来查看视图层级的布局:

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
        [self printViewHierarchy:self.tabBarController.view];
    }
    
    - (void)printViewHierarchy:(UIView *)superView
    {
        static uint level = 0;
        for(uint i = 0; i < level; i++){
            printf("\t");
        }
    
        const char *className = NSStringFromClass([superView class]).UTF8String;
        const char *frame = NSStringFromCGRect(superView.frame).UTF8String;
        printf("%s:%s\n", className, frame);
    
        ++level;
        for(UIView *view in superView.subviews){
            [self printViewHierarchy:view];
        }
        --level;
    }
    结果如下:
    
    UILayoutContainerView:{{0, 0}, {320, 480}}
        UITransitionView:{{0, 0}, {320, 480}}
            UIViewControllerWrapperView:{{0, 0}, {320, 480}}
                UIView:{{0, 0}, {320, 480}}
        UITabBar:{{0, 431}, {320, 49}}
            _UITabBarBackgroundView:{{0, 0}, {320, 49}}
                _UIBackdropView:{{0, 0}, {320, 49}}
                    _UIBackdropEffectView:{{0, 0}, {320, 49}}
                    UIView:{{0, 0}, {320, 49}}
            UITabBarButton:{{2, 1}, {156, 48}}
                UITabBarSwappableImageView:{{54, 2}, {48, 32}}
                UITabBarButtonLabel:{{68, 35}, {21, 12}}
            UITabBarButton:{{162, 1}, {156, 48}}
                UITabBarSwappableImageView:{{54, 2}, {48, 32}}
                UITabBarButtonLabel:{{60, 35}, {36, 12}}
            UIImageView:{{0, -0.5}, {320, 0.5}}
    2019-07-17 19:59:04
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载