0

我正在尝试使用Material Design Components 的 Xamarin 端口,以便直接在 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();

    }

感谢您的帮助!

4

1 回答 1

1

你可以调整HeaderView'sMinimumHeight来扩展你的NavigationBar像这样:

appBar.HeaderViewController.HeaderView.MinimumHeight = 150;

您还可以设置MaximumHeight在拉动时限制其最大高度:

appBar.HeaderViewController.HeaderView.MaximumHeight = 400;
于 2018-02-22T07:25:43.830 回答