xcode 去除导航栏/搜索栏底部的黑线
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13745612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove the dark Line at the bottom of Navigationbar/Searchbar
提问by xapslock
I want to make a clean white Design. So, I set the tintColor
property to whiteColor
, but there are these dark Lines under the UINavigationBar
and UISearchBar
.
我想做一个干净的白色设计。所以,我将tintColor
属性设置为whiteColor
,但在UINavigationBar
和下有这些暗线UISearchBar
。
Do some one know, how to remove the dark Lines or how to change the Color?
有人知道,如何去除暗线或如何改变颜色?
回答by Nick
add a method to UIImage by category
按类别向 UIImage 添加方法
+ (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
and just set
并设置
[self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor whiteColor]]];
回答by Septronic
This is what I did, and seemed to work, it is a further development of this link. I changed the explicit width declaration to a dynamic one, so that it will be the size of the view if you change view size or not:
这就是我所做的,并且似乎有效,这是此链接的进一步发展。我将显式宽度声明更改为动态声明,这样无论您是否更改视图大小,它将是视图的大小:
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 43, self.view.frame.size.width, 1)];
[overlayView setBackgroundColor:[UIColor whiteColor]];
[navBar addSubview:overlayView]; // navBar is your UINavigationBar instance
[overlayView release];
I found the stuff here: How to remove UINavigatonItem's border line
我在这里找到了这些东西: 如何删除 UINavigatonItem 的边框线
回答by Nailer
From iOS 7 UINavigationBar has a shadowImage property that you can set to nil.
从 iOS 7 UINavigationBar 有一个 shadowImage 属性,您可以将其设置为 nil。