UISearchBar底线

问题描述 投票:0回答:1

如何在UITableViewController中删除UISearchBar底线?

也可以应用Swift解决方案。

enter image description here

这是我的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();

我尝试了几乎所有我在互联网上找到的解决方案。

不要工作下一个解决方案:

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;
ios swift xamarin xamarin.ios
1个回答
1
投票

这是解决方案:

public override void ViewWillLayoutSubviews()
{
    base.ViewWillLayoutSubviews();
    ((UIImageView) NavigationItem.SearchController.SearchBar.Superview?.Subviews.First().Subviews.First()).Bounds = CGRect.Null;
}
© www.soinside.com 2019 - 2024. All rights reserved.