ios - UISearchBar 底线

标签 ios swift xamarin xamarin.ios

如何删除 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();

我尝试了几乎所有在 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/

相关文章:

ios - evaluateJavaScript 等待 JS 回调

xamarin - 项目链接器扩展不会安装在 Visual Studio 2013 Pro 上

ios - FBSDKShareDialog 在应该发布时取消

ios - 带有平移手势的 CATransition Cube

ios - 使用 NSURLConnection 获取 302 HTTP 重定向的响应主体

swift - 仅当 View Controller 通过滑动或后退按钮按下而不是通过切换选项卡从堆栈中弹出时才发送数据

细胞中的 swift GestureRecognizer

android - xamarin android 推送通知只工作一次

ios - Xamarin 在 ios 上形成 zxing ZXingScannerView

ios - 如何通过更改方向在layoutSubview中使用CAGradientLayer