c# - MDCTabBar 和 MDCNavigationBar 将 NavigationBar 向上推

标签 c# ios xamarin material-components

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

enter image description here

这是我的 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;

关于c# - MDCTabBar 和 MDCNavigationBar 将 NavigationBar 向上推,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48913256/

相关文章:

Xamarin 表单选项卡式分页滑动调用事件

c# - 混合私有(private) NuGet 提要和 NEST 时“dotnet restore”失败

c# - WPF Datagrid 排序索引问题

c# - 如何使用 Entity Framework 将多个表的数据绑定(bind)到 datagridview 并使用 CRUD 操作?

c# - 使用 Fluent API 添加唯一标识符

iOS:应用程序中的模型架构

ios - 错误 ITMS-90474 : "Invalid Bundle. iPad 多任务支持需要这些方向:

ios - 将手势转发到 super View

ios - xamarin UITableViewController 单元格出队

c# - 是真的使用匿名或动态类型作为参数吗?