如何设置状态栏背景颜色iOS 7 [英] How to set Status bar background color iOS 7

查看:112
本文介绍了如何设置状态栏背景颜色iOS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 6外观......

iOS 6 look...

同样的方式我想在iOS 7中显示状态栏,如

Same way i would like to display status bar in iOS 7 like

看到这个

但是我的实际输出(重叠)

but My actual output (Overlap)

我试过以下逻辑

open your info.plist and set "View controller-based status bar appearance" = NO

它在我的代码中不起作用,

it's not working in my code,,,

推荐答案

你必须做两件事。首先是打开 info.plist 并设置查看基于控制器的状态栏外观=否

You have to do 2 things. First is to open your info.plist and set "View controller-based status bar appearance" = NO

第二个是将这些行添加到应用程序:didFinishLaunchingWithOptions

And the second is to add this lines to application:didFinishLaunchingWithOptions

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, 0,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);
    }
}

这篇关于如何设置状态栏背景颜色iOS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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