如何删除UITableViewController中的UISearchBar底线?
也可以应用快速解决方案。
这是我的VC代码:
NavigationController.NavigationBar.PrefersLargeTitles = true;
NavigationController.NavigationItem.LargeTitleDisplayMode = UINavigationItemLargeTitleDisplayMode.Automatic;
NavigationItem.HidesSearchBarWhenScrolling = false;
var searchController = new UISearchController(searchResultsController: null);
NavigationItem.SearchController = searchController;
NavigationItem.SearchController.DefinesPresentationContext = true;
NavigationItem.SearchController.DimsBackgroundDuringPresentation = false;
对于 AppDeletage.cs
UINavigationBar.Appearance.Translucent = false;
UINavigationBar.Appearance.ShadowImage = new UIImage();
我尝试了几乎所有在Internet上找到的解决方案。
不要使用下一个解决方案:
UISearchBar.Appearance.BackgroundImage = null;
UISearchBar.Appearance.BackgroundColor= UIColor.Clear;
NavigationItem.SearchController.Layer.BorderWidth = 0
NavigationItem.SearchController.Layer.BorderColor = UIColor.White.CGColor
NavigationItem.SearchController.SearchBar.ClipsToBounds = true;
答案 0 :(得分:1)
这是解决方法:
public override void ViewWillLayoutSubviews()
{
base.ViewWillLayoutSubviews();
((UIImageView) NavigationItem.SearchController.SearchBar.Superview?.Subviews.First().Subviews.First()).Bounds = CGRect.Null;
}