[英]White line under UINavigationBar in IOS 7
I have a UITableViewController
with a UISearchDisplayController
and UISearchBar
. 我有一个
UITableViewController
与UISearchDisplayController
和UISearchBar
。 I'm seeing a white line under the navbar when I present the view in a UITabBarController
. 当我在
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. 当我在
UINavigationController
中以模态方式呈现视图时,该行是灰色或黑色(我无法分辨),它看起来非常正常。 Any ideas? 有任何想法吗?
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) 我有同样的问题,无法弄清楚它来自哪里(它到处都存在而且它不是
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];
}
I had the same problem too, after trying with a lot of methods,I find this way solved my problem 我也遇到了同样的问题,在尝试了很多方法之后,我发现这种方式解决了我的问题
[[UISearchBar appearance] setBackgroundColor:[UIColor yourColor]];
write it in your viewDidLoad. 将它写在viewDidLoad中。
尝试将UISearchBar上的clipsToBounds属性设置为YES。
The white line is probably the shadowImage of navigation bar. 白线可能是导航栏的shadowImage 。
Try setting it as: 尝试将其设置为:
self.navigationController.navigationBar.shadowImage = [UIImage new];
Use following line of the code : 使用以下代码行:
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];
here is my posted Answer : Horizontal Separator NavBar IOS 7 这是我发布的答案: 水平分隔符NavBar IOS 7
How to remove UINavigatonItem's border line 如何删除UINavigatonItem的边框线
Swift version of Divya's answers 迅捷版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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.