private void InitView() { var sheet = new StackView() { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = BackColor, AutoresizingMask = UIViewAutoresizing.FlexibleWidth, Alignment = UIStackViewAlignment.Fill, Distribution = UIStackViewDistribution.Fill, Axis = UILayoutConstraintAxis.Vertical }; var title = CreateTitle(_config.Title); sheet.AddArrangedSubview(title); sheet.AddArrangedSubview(CreateSeparator()); _textField = CreateTextField(); sheet.AddArrangedSubview(_textField); sheet.AddArrangedSubview(CreateSeparator()); var buttons = CreateOkCancelButtonsView(_config.OnAction, _config.OkText, _config.CancelText); sheet.AddArrangedSubview(buttons); _activeview = sheet; this.View.AddSubview(sheet); this.View.AddConstraint(NSLayoutConstraint.Create(this.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, sheet, NSLayoutAttribute.Bottom, 1, 0)); this.View.AddConstraint(NSLayoutConstraint.Create(this.View, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, sheet, NSLayoutAttribute.Leading, 1, 0)); this.View.AddConstraint(NSLayoutConstraint.Create(this.View, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, sheet, NSLayoutAttribute.Trailing, 1, 0)); }
private PaddedUITextField CreateTextField() { var textField = new PaddedUITextField { Placeholder = _config.Placeholder, Text = _config.Text, ShouldChangeCharacters = (textfield, range, replacementString) => { var newLength = textfield.Text.Length + replacementString.Length - range.Length; return(_config.MaxLength == null ? newLength <= TextFieldDefaultMaxLength : newLength <= _config.MaxLength.Value); }, BackgroundColor = UIColor.Clear, TextColor = MainTextUiColor, Font = UIFont.SystemFontOfSize(TextSize), TextAlignment = UITextAlignment.Left }; textField.HeightAnchor.ConstraintEqualTo(RowHeight).Active = true; textField.Padding = new CGRect(10, 0, 10, 0); return(textField); }