我正在尝试使用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();
}
感谢您的帮助!
答案 0 :(得分:1)
您可以调整HeaderView
&#39; MinimumHeight
以展开NavigationBar
,如下所示:
appBar.HeaderViewController.HeaderView.MinimumHeight = 150;
此外,您可以将MaximumHeight
设置为在拉动时限制其最大高度:
appBar.HeaderViewController.HeaderView.MaximumHeight = 400;