2

我无法弄清楚如何让 ios 7 中的状态栏使用导航栏的颜色。我与滑动菜单导航库UINavigationController一起使用。SWRevealController

这是页面现在的样子:

在此处输入图像描述

我希望状态栏继承导航栏的灰色。我怎样才能做到这一点?

4

5 回答 5

2

您可以修改项目的 Info.plist 并将“查看基于控制器的状态栏外观”设置为 NO

在 AppDelegate 你必须添加

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

到 AppDelegates 的 didFinishLaunchingWithOptions 方法。

希望它对你有用。

于 2014-02-26T05:27:27.210 回答
2

在 iOS 7 导航栏图像高度为 64 像素。您需要创建两张图片,一张用于 iOS 7 的导航栏,高度为 64 像素,另一张用于 iOS 6 或更低,高度为 44 像素

然后使用此代码

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)?YES:NO) {
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"your 64 image"] forBarMetrics:UIBarMetricsDefault];
 } 
else 
{
 [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"your 44 image"] forBarMetrics:UIBarMetricsDefault];
}
于 2014-02-26T05:48:17.860 回答
1

制作一个自定义视图并将导航栏的颜色设置为该视图,将此视图放在状态栏的位置,并将状态栏的颜色更改为透明。快乐编码

于 2014-02-26T05:12:06.167 回答
0
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)?YES:NO) {
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"newImage.png"] forBarMetrics:UIBarMetricsDefault];
 } 
else 
{
 [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"previousImage.png"] forBarMetrics:UIBarMetricsDefault];
}
于 2014-02-26T05:17:14.710 回答
0

将导航栏的委托设置为当前视图控制器并将导航栏附加到顶部。

class ViewController: UIViewController, UINavigationBarDelegate {

@IBOutlet weak var navigationBar: UINavigationBar!

override func viewDidLoad() {
    navigationBar.delegate = self
}

func positionForBar(bar: UIBarPositioning) -> UIBarPosition {
    return .TopAttached
}
于 2016-08-22T11:34:41.080 回答