在ios7中获取视图底部的黑色阴影条

时间:2014-04-17 07:38:37

标签: ios7 ios7.1

我正在做一个应用程序。我使用下面的代码来停止覆盖我视图中的状态栏

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
    self.window.clipsToBounds = YES;
    [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];

    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        self.window.frame =  CGRectMake(20, 20,self.window.frame.size.width-20,self.window.frame.size.height);
        self.window.bounds = CGRectMake(20, 0, self.window.frame.size.width, self.window.frame.size.height);
    } else
    {
        self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
        self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
    }
}

但是,如果我这样做,我在模拟器中的视图底部得到黑色透明条。但在设备中我得到黑色。它正确在ios6中工作,只有问题i ios 7如下。< / p>

enter image description here

1 个答案:

答案 0 :(得分:1)

我在带有默认导航栏的演示中运行了您的代码,发现了相同的黑色内容。所以做了一些改动,下面是一个 -

if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
    self.window.frame =  CGRectMake(0, 0,self.window.frame.size.width,self.window.frame.size.height);
    self.window.bounds = CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height);
} else
{
    self.window.frame =  CGRectMake(0,0,self.window.frame.size.width,self.window.frame.size.height);
    self.window.bounds = CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height);
}

你可以试一试,如果有什么事情发生,请告诉我。