【发布时间】:2014-04-14 14:57:02
【问题描述】:
我正在使用 iOS 7 和情节提要开发一个应用程序。我有几个视图控制器。我想要做的是根据导航栏颜色更改状态栏颜色。但是每个视图控制器都有不同颜色的导航栏。我知道我可以通过向 info.plist 添加一个标志和如下代码来更改状态栏颜色:
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);
}
}
但是如何更改每个ViewController 的颜色?
【问题讨论】:
-
你在说this吗?