如何设置状态栏背景颜色iOS 7

iOS 6看…

在这里输入图像说明

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

看到这个

在这里输入图像说明

但我的实际输出(重叠)

我试过以下的逻辑

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

它不工作在我的代码,,,

你必须做2件事。 首先打开你的info.plist并设置"View controller-based status bar appearance" = NO

第二个是将这些行添加到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); } } 

阅读这篇文章: http : //www.appcoda.com/customize-navigation-status-bar-ios-7/

 #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)]; 

把你的框架向下移动20个像素。 你可以尝试在你的ViewWillapar或DidAppear中写这个

 CGRect frame = self.view.frame; frame.origin.y = 20; if (self.view.frame.size.height == 1024 || self.view.frame.size.height == 768) { frame.size.height -= 20; } self.view.frame = frame; 

现在,在applicationDidFinishLaunching中将窗口背景颜色设置为黑色,并将状态栏字体设置为白色(StatusBarContentLight)

请记住,我所build议的并不是完美的解决scheme,但是可以很好地解决问题。 应用程序更改方向时也使用相同的代码(ShouldAutorotate)