public override void ViewDidLoad() { base.ViewDidLoad(); _container = new UIView { BackgroundColor = UIColor.White } .AddTo(View); _container.ActivateConstraints( _container.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor), _container.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor), _container.BottomAnchor.ConstraintEqualTo(View.BottomAnchor), _container.HeightAnchor.ConstraintEqualTo(120) ); _okButton = new UIButton(UIButtonType.System) .AddTo(_container) .SetButtonTitle("Done"); _okButton.ActivateConstraints( _okButton.RightAnchor.ConstraintEqualTo(_container.RightAnchor, -12), _okButton.TopAnchor.ConstraintEqualTo(_container.TopAnchor, 4) ); var scroll = new UIScrollView { ContentInset = new UIEdgeInsets(0, 10, 0, 10), ShowsHorizontalScrollIndicator = false, Bounces = false }.AddTo(_container); scroll.FullSizeOf(_container, new UIEdgeInsets(35, 0, 0, 0)); _stack = new UIStackView { Axis = UILayoutConstraintAxis.Horizontal, Alignment = UIStackViewAlignment.Fill, Distribution = UIStackViewDistribution.EqualSpacing, Spacing = 4 }.AddTo(scroll); _stack.FullSizeOf(scroll); foreach (var option in _options) { _stack.AddArrangedSubview(new ToggleButton(option.Key, option.Value, 50, 75)); } }
public override void ViewDidLoad() { base.ViewDidLoad(); _container = new RoundedView(4) { BackgroundColor = UIColor.Blue, ClipsToBounds = true } .SetBorder(1, UIColor.White) .AddTo(View); _container.ActivateConstraints(_container.WidthAnchor.ConstraintLessThanOrEqualTo(View.WidthAnchor, 0.7f)); _container.CenterIn(View); var stack = new UIStackView { Axis = UILayoutConstraintAxis.Vertical, Alignment = UIStackViewAlignment.Center, Spacing = 8 }.AddTo(_container); var buttonStack = new UIStackView { Axis = UILayoutConstraintAxis.Horizontal, Alignment = UIStackViewAlignment.Fill, Distribution = UIStackViewDistribution.Fill, Spacing = 12 }; _titleLabel = new UILabel { Text = _title, Font = UIFont.BoldSystemFontOfSize(16), TextColor = UIColor.White, Lines = 0 }; _messageLabel = new UILabel { Text = _message, TextAlignment = UITextAlignment.Center, Font = UIFont.SystemFontOfSize(15), TextColor = UIColor.White, Lines = 0 }; var separator = new UIView { BackgroundColor = UIColor.White }; separator.ConstraintSize(200, 1); _okButton = new UIButton(); _okButton.SetTitle(_ok, UIControlState.Normal); _okButton.SetTitleColor(UIColor.White, UIControlState.Normal); _cancelButton = new UIButton(); _cancelButton.SetTitle(_cancel, UIControlState.Normal); _cancelButton.SetTitleColor(UIColor.White, UIControlState.Normal); stack.AddArrangedSubview(_titleLabel); stack.AddArrangedSubview(_messageLabel); stack.AddArrangedSubview(separator); stack.AddArrangedSubview(buttonStack); stack.FullSizeOf(_container, 10); buttonStack.AddArrangedSubview(_okButton); buttonStack.AddArrangedSubview(_cancelButton); _messageLabel.Hidden = _message == null; _cancelButton.Hidden = _cancel == null; }