代码之家  ›  专栏  ›  技术社区  ›  esskar

Xamarin.IOS上的表单:删除SearchBar和NavigationBar之间的空格

  •  0
  • esskar  · 技术社区  · 8 年前

    在我的页面中,我在列表视图上方添加了一个搜索栏。它工作得很好,但我看到导航栏和搜索栏之间有一条小线。有人知道怎么取下来吗? 谢谢

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

    Space between navigation bar and search bar

    1 回复  |  直到 8 年前
        1
  •  2
  •   Arvind Chourasiya    8 年前

    若要移除底部阴影线,可以使用自定义渲染器。这正是你所需要的。

    [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