MDCTabBar 和 MDCNavigationBar 将 NavigationBar 向上推

MDCTabBar with MDCNavigationBar pushes NavigationBar up

我正在尝试使用 Xamarin port of Material Design Components 来直接在 AppBar 组件下添加一个 tabBar,但是当我将 TabBar 添加为 BottomBar 视图时,它会将 NavigationBar 向上推,我不确定我是什么做错了。

这是我的 ViewDidLoad():

public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        Styler.CellStyle = MDCCollectionViewCellStyle.Card;
        AddChildViewController(appBar.HeaderViewController);
        appBar.HeaderViewController.HeaderView.TrackingScrollView = CollectionView;

        appBar.NavigationBar.BackgroundColor = UIColor.Gray;
        appBar.NavigationBar.TintColor = UIColor.White;
        var attr = new NSDictionary<NSString, NSObject>(
        UIStringAttributeKey.ForegroundColor, UIColor.White);
        appBar.NavigationBar.TitleTextAttributes = attr;

        var tabBar = new MDCTabBar()
        {
            ItemAppearance = MDCTabBarItemAppearance.Titles,
            Alignment = MDCTabBarAlignment.CenterSelected,
            AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin
        };
        tabBar.Items = new UITabBarItem[] {
            new UITabBarItem("Event 1", null, 0),
            new UITabBarItem("Event 2", null, 0)
        };
        tabBar.SizeToFit();
        appBar.HeaderStackView.BottomBar = tabBar;

        appBar.HeaderViewController.HeaderView.BackgroundColor = App.AFSabreDark;
        appBar.HeaderStackView.BackgroundColor = UIColor.Blue;

        appBar.AddSubviewsToParent();

        refreshControl.ValueChanged += async (sender, e) =>
        {
            await RefreshAsync();
        };

        CollectionView.Add(refreshControl);
        CollectionView.RegisterClassForCell(typeof(MDCCollectionViewTextCell), cellId);

        model.DataUpdated += (sender, e) => {
            CollectionView.ReloadData();
        };
        model.PullData();

    }

感谢您的帮助!

您可以像这样调整 HeaderViewMinimumHeight 来扩展您的 NavigationBar

appBar.HeaderViewController.HeaderView.MinimumHeight = 150;

你也可以设置 MaximumHeight 限制拉动时的最大高度:

appBar.HeaderViewController.HeaderView.MaximumHeight = 400;