在IOS 7中的UINavigationBar下的白线

我有一个UITableViewControllerUISearchDisplayControllerUISearchBar 。 当我在UITabBarController呈现视图时,我在导航栏下看到一条白线。 当我在UINavigationController中以模态方式呈现视图时,该线条是灰色或黑色(我无法说出),看起来完全正常。 有任何想法吗?

在这里输入图像说明

我有同样的问题,不知道它是从哪里来的(它到处都是,而不是shadowImage ),结果是以下修复(在我的UINavigationController子类中)

 // Fixes strange line under NavigationBar { UIView * view = [[UIView alloc] init]; view.backgroundColor = self.navigationBar.barTintColor; CGRect rect = view.frame; rect.origin.x = 0.f; rect.origin.y = self.navigationBar.frame.size.height; rect.size.width = self.navigationBar.frame.size.width; rect.size.height = 1.f; view.frame = rect; [self.navigationBar addSubview:view]; } 

我也有同样的问题,尝试了很多方法后,我发现这样解决了我的问题

 [[UISearchBar appearance] setBackgroundColor:[UIColor yourColor]]; 

把它写在你的viewDidLoad中。

尝试将UISearchBar上的clipsToBounds属性设置为YES。

白线可能是导航栏的阴影图像 。

尝试将其设置为:

 self.navigationController.navigationBar.shadowImage = [UIImage new]; 

使用下面的代码行:

 UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 43, 320, 1)]; [overlayView setBackgroundColor:[UIColor whiteColor]]; // set color accordingly [navBar addSubview:overlayView]; // navBar is your UINavigationBar instance [overlayView release]; 

这里是我发布的答案: 水平分隔符NavBar IOS 7

如何删除UINavigatonItem的边界线

迅速版本的Divya的答案

  let hideLineView = UIView(frame: CGRect(x: 0, y: navigationController!.navigationBar.frame.size.height, width: view.frame.size.width, height: 1)) hideLineView.backgroundColor = UIColor.white navigationController!.navigationBar.addSubview(hideLineView)