// public Container() { ClipsToBounds = true; _state = State.Collapsed; Layer.BackgroundColor = UIColor.White.CGColor; Layer.BorderColor = UIColor.LightGray.CGColor; Layer.BorderWidth = 1; Header = this.Add<Header>(); _content = this.Add<UIView>(); _content.ClipsToBounds = true; Header.BackgroundColor = UIColor.White; Header.Layer.BorderColor = UIColor.LightGray.CGColor; Header.Layer.BorderWidth = 1; Header .Anchor(NSLayoutAttribute.Top, this, NSLayoutAttribute.Top) .Anchor(NSLayoutAttribute.Left, this, NSLayoutAttribute.Left) .Anchor(NSLayoutAttribute.Right, this, NSLayoutAttribute.Right); _content .Anchor(NSLayoutAttribute.Top, Header, NSLayoutAttribute.Bottom) .Anchor(NSLayoutAttribute.Left, this, NSLayoutAttribute.Left) .Anchor(NSLayoutAttribute.Right, this, NSLayoutAttribute.Right) .Anchor(NSLayoutAttribute.Bottom, this, NSLayoutAttribute.Bottom); }
private void LayoutButtons() { if (this.buttons != null) { int numberOfRows = this.layoutHandler.CalculateNumberOfRows(this.buttons.Count()); if (numberOfRows < 1) { throw new InvalidOperationException("The layout handler calculated the number of rows as less than 1."); } foreach (UIView row in this.buttonRows) { row.RemoveFromSuperview(); } this.buttonRows.Clear(); this.buttonHeightConstraints.Clear(); for (int i = 0; i < numberOfRows; i++) { IEnumerable <SegmentedControlItem> itemsForRow = this.layoutHandler.SelectItemsForRow(this.buttons.Select(item => item.Item2), i); IEnumerable <UIButton> buttonsForRow = this.buttons.Where(item => itemsForRow.Contains(item.Item2)).Select(item => item.Item1); this.AddRow(buttonsForRow); } UIView topRow = this.buttonRows.First(); topRow.Anchor(AnchorEdges.Horizontal | AnchorEdges.Top); for (int i = 1; i < this.buttonRows.Count; i++) { UIView currentRow = this.buttonRows[i]; currentRow.Anchor(AnchorEdges.Horizontal); currentRow.AnchorBelow(topRow); topRow = currentRow; } this.buttonRows.Last().Anchor(AnchorEdges.Bottom); } }