iOS7中的StatusBar背景色

时间:2014-03-13 09:56:40

标签: ios7 uistatusbar ios7.1 ios7-statusbar

我正在处理从ios6开始兼容的应用程序。在iOS 7状态栏中是重叠的视图和导航栏。我想要iOS 6风格的状态栏。喜欢它应该出现在所有UI对象,视图,Viewcontroller和导航控制器之上。我们怎样才能做到这一点?

2 个答案:

答案 0 :(得分:1)

要解决重叠问题,请尝试使用此链接Status bar and navigation bar issue in IOS7

并且对于使用类似于ios 6的状态栏样式,此链接可以帮助您Change StatusBar style

在你的app delegate的applicationDidFinishLaunching方法中:

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];

设置UIStatusBarStyleBlackTranslucent / UIStatusBarStyleBlackOpaque以获取类似于iOS6的状态栏。

希望这可以帮到你

答案 1 :(得分:1)

我迟到了这个答案,但我只想分享我的所作所为,这基本上是 最简单的解决方案

首先 - > 转到info.plist文件并添加Status Bar Style->Transparent Black Style(Alpha of 0.5)

现在,它来了: -

在AppDelegate.m中添加此代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
     //Whatever your code goes here
  if(kDeviceiPad){

     //adding status bar for IOS7 ipad
         if (IS_IOS7) {
              UIView *addStatusBar = [[UIView alloc] init];
              addStatusBar.frame = CGRectMake(0, 0, 1024, 20);
              addStatusBar.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; //change this to match your navigation bar
              [self.window.rootViewController.view addSubview:addStatusBar];
                    }
                }
    else{

         //adding status bar for IOS7 iphone
        if (IS_IOS7) {
            UIView *addStatusBar = [[UIView alloc] init];
            addStatusBar.frame = CGRectMake(0, 0, 320, 20);
            addStatusBar.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; //You can give your own color pattern
            [self.window.rootViewController.view addSubview:addStatusBar];
        }

    return YES;
   }