如何删除 UITableViewController 中的 UISearchBar 底线?
也可以应用 Swift 解决方案。
这是我的 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;
最佳答案
解决方法:
public override void ViewWillLayoutSubviews()
{
base.ViewWillLayoutSubviews();
((UIImageView) NavigationItem.SearchController.SearchBar.Superview?.Subviews.First().Subviews.First()).Bounds = CGRect.Null;
}
关于ios - UISearchBar 底线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54034187/