public MDSegmentedControl(MDTabBar bar) { Tabs = new NSMutableArray <UIView>(); IndicatorView = new UIView(new CGRect(0, kMDTabBarHeight - kMDIndicatorHeight, 0, kMDIndicatorHeight)); IndicatorView.Tag = int.MaxValue; AddSubview(IndicatorView); AddTarget(SelectionChanged, UIControlEvent.ValueChanged); TabBar = bar; }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any addi tional setup after loading the view, typically from a nib. var tabBar = new MDTabBar { TranslatesAutoresizingMaskIntoConstraints = false }; tabBar.SetItems(new NSObject[] { new NSString("Tab 1"), new NSString("Tab 2") }); View.AddSubview(tabBar); tabBar.AddConstraint(NSLayoutConstraint.Create( tabBar, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 56 )); View.AddConstraint(NSLayoutConstraint.Create( tabBar, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1, 0 )); View.AddConstraint(NSLayoutConstraint.Create( tabBar, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1, 0 )); View.AddConstraint(NSLayoutConstraint.Create( tabBar, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1, 0 )); }
public override void DidChangeSelectedIndex(MDTabBar tabBar, nuint selectedIndex) { SelectedIndexLabel.Text = selectedIndex + ""; }