7中UINavigationBar下的白线

7中UINavigationBar下的白线

本文介绍了IOS 7中UINavigationBar下的白线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITableViewController ,带有 UISearchDisplayController UISearchBar 。当我在 UITabBarController 中显示视图时,我在导航栏下面看到一条白线。当我在 UINavigationController 中以模态方式呈现视图时,该行是灰色或黑色(我无法分辨),它看起来很正常。有什么想法?

I have a UITableViewController with a UISearchDisplayController and UISearchBar. I'm seeing a white line under the navbar when I present the view in a UITabBarController. When I present the view modally in a UINavigationController, the line is either gray or black (I can't tell) and it looks perfectly normal. Any ideas?

推荐答案

我有同样的问题,无法弄清楚它来自哪里(它存在于任何地方而且它不是 shadowImage ),最后得到以下修复(在我的 UINavigationController 子类中)

I had the same problem, couldn't figure out from where it did came from (it was present everywhere and it was NOT the shadowImage), ended up with the following fix (in my UINavigationController subclass)

// 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];
}

这篇关于IOS 7中UINavigationBar下的白线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:24