我有一个和UITableViewController
一个。当我在. 当我在 a 中模态显示视图时,这条线是灰色或黑色(我不知道),它看起来非常正常。有任何想法吗?UISearchDisplayController
UISearchBar
UITabBarController
UINavigationController
user594161
问问题
1907 次
6 回答
6
我有同样的问题,无法弄清楚它是从哪里来的(它无处不在,它不是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];
}
于 2014-01-25T19:16:27.790 回答
4
我也遇到了同样的问题,尝试了很多方法后,我发现这种方法解决了我的问题
[[UISearchBar appearance] setBackgroundColor:[UIColor yourColor]];
把它写在你的 viewDidLoad 中。
于 2014-02-18T07:17:33.663 回答
2
于 2013-11-08T07:54:13.920 回答
1
尝试将 UISearchBar 上的 clipsToBounds 属性设置为 YES。
于 2013-11-08T07:49:10.710 回答
1
使用以下代码行:
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];
这是我发布的答案: Horizontal Separator NavBar IOS 7
于 2014-02-18T07:22:43.637 回答
0
Divya 答案的 Swift 版本
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)
于 2017-11-16T10:53:46.963 回答