Xamarin.Forms on IOS:删除搜索栏和导航栏之间的 space

Xamarin.Forms on IOS: Remove space between SearchBar and NavigationBar

在我的页面中,我在 ListView 上方添加了一个 SearchBar。它工作正常,但我看到 NavigationBar 和 SearchBar 之间有一条小线。任何人都知道如何删除它? 谢谢

    <StackLayout Orientation="Vertical">
    <SearchBar 
        CancelButtonColor="White"
        BackgroundColor="{x:Static local:Consts.PrimaryColor}"
        IsVisible="{Binding IsSearchVisible, Mode=OneWay}"
    />
    <ListView

要删除底部阴影线,您可以使用自定义渲染器。这将完全满足您的需求。

[assembly: ExportRenderer(typeof(NavigationPage), typeof(NoLineNavigationRenderer))] 
namespace MyMobileProject.iOS {
    public class NoLineNavigationRenderer : NavigationRenderer {

        public override void ViewDidLoad(){
            base.ViewDidLoad();
            // remove lower border and shadow of the navigation bar
            NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            NavigationBar.ShadowImage = new UIImage ();
        }
    }
}

更多信息请访问this