我正在尝试使用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();
}
感谢您的帮助!