导航栏和视图之间的分隔符 - iOS 7 [英] Separator between navigation bar and view - iOS 7

查看:190
本文介绍了导航栏和视图之间的分隔符 - iOS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 7中,导航栏和视图之间有一个灰色分隔符。

In iOS 7 there's a grey separator between the navigation bar and the view.

回到iOS 6,没有那条水平线,因此视图会与导航栏混合,就像它们是相同的图像一样。现在我不知道如何删除它...

Back in iOS 6, there wasn't that horizontal line, thus the view would blend in with the navigation bar as if they were the same image. Now I don't know how to remove it...

我已经尝试调整视图/导航栏的大小,但它没有帮助。有什么想法?

I've tried resizing the view / navigation bar, but it doesn't help. Any ideas?

推荐答案

尝试

self.navigationController.navigationBar.translucent = NO;

viewDidLoad 方法中让我知道:)

如果你在每个ViewController上都需要这个效果,你可以这样做:

If you need this effect on every ViewController, you could simply do:

[[UINavigationBar appearance] setTranslucent:NO]

或者你需要做这是您首先实例化导航控制器的地方。例如,如果导航控制器是您的应用程序的根视图控制器,您只需执行

Or you'll need to do this where you first instantiate the navigation controller. For example, if the navigation controller is the root view controller of your app you can simply do

UINavigationController *nav = (UINavigationController *)self.window.rootViewController;
nav.navigationBar.translucent = NO;

在你的

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

如果,在另一端,你通过segue实例化它(在适当的视图控制器中)

If, on the other end, you instantiate it through a segue you could do (in the appropriate view controller)

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
   if([segue.identifier isEqualToString:@"navController"]){     
       UINavigationController *nav = (UINavigationController *)segue.destinationViewController;
       nav.navigationBar.translucent = NO;
   }
}

等等(如果你实际上是在实例化它从代码中,它应该是最简单的选项。)

And so on (if you're actually instantiating it from code, it should be the easiest option).

这篇关于导航栏和视图之间的分隔符 - iOS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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