隐藏tabBar显示Ios7中的黑条 [英] Hiding tabBar showing black bar in Ios7

查看:68
本文介绍了隐藏tabBar显示Ios7中的黑条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码隐藏TabBar:

I am using this code to hide the TabBar:

self.tabBarController.tabBar.hidden=YES;

我在项目中隐藏了tabBarController。但它在Ios7的视图底部显示了黑条。当我回到相同的视图时它看起来很好。非常感谢。

I am hiding tabBarController in my project.but it showing black bar in bottom of the view in Ios7.When i go back to the same view it is looking good.any help will be appreciated.

推荐答案

注意:它是解决方案仅限iOS6和7。

NOTE: It is solution for iOS6 and 7 only.

在iOS 7中,为了扩展可点击区域并在隐藏的UITabBar上隐藏黑条,您应该为您启用扩展边缘 - 在不透明条形下选项UIViewController中。

In iOS 7 to extend clickable area and hide black bar on place of hidden UITabBar you should enable 'Extend Edges - Under Opaque Bars' option for you UIViewController.

或者你可以通过编程方式设置这个属性:

Or you can set this property programmatically:


[self setExtendedLayoutIncludesOpaqueBars:YES]

[self setExtendedLayoutIncludesOpaqueBars:YES]

下面是隐藏或移动TabBar for iOS 6/7的代码示例:

Here is example of code that hide or move TabBar for iOS 6/7:

UITabBarController *bar = [self tabBarController];
if ([self respondsToSelector:@selector(setExtendedLayoutIncludesOpaqueBars:)]) {
    //iOS 7 - hide by property
    NSLog(@"iOS 7");
    [self setExtendedLayoutIncludesOpaqueBars:YES];
    bar.tabBar.hidden = YES;
} else {
    //iOS 6 - move TabBar off screen
    NSLog(@"iOS 6");
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    float height = screenRect.size.height;
    [self moveTabBarToPosition:height];
}

//Moving the tab bar and its subviews offscreen so that top is at position y
-(void)moveTabBarToPosition:(int)y {

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

    for(UIView *view in self.tabBarController.view.subviews) {
        if ([view isKindOfClass:[UITabBar class]]) {
            [view setFrame:CGRectMake(view.frame.origin.x, y, view.frame.size.width, view.frame.size.height)];
        } else {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, y)];
            view.backgroundColor = [UIColor blackColor];
        }
    }
}

移动标签栏的功能屏幕来自这篇文章

Function to moving the Tab Bar offscreen got from this post.

这篇关于隐藏tabBar显示Ios7中的黑条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆