public override void ViewDidLoad() { Title = _title; View.AddSubview(new UILabel { Frame = new RectangleF(20, 10, 280, 40), TextAlignment = UITextAlignment.Center, Font = UIFont.SystemFontOfSize(20), TextColor = UIColor.Gray, Text = "Type Amount" }); _totalField = new UIDecimalField(_amount) { Frame = new RectangleF(50, 50, 220, 40), TextAlignment = UITextAlignment.Center, Font = UIFont.BoldSystemFontOfSize(30), Text = _amount.ToString("N2"), EnablesReturnKeyAutomatically = true, BorderStyle = UITextBorderStyle.RoundedRect, }; View.AddSubview(_totalField); _totalField.BecomeFirstResponder(); }
public override void ViewDidLoad () { Title = _title; View.AddSubview(new UILabel { Frame = new RectangleF(20,10,280,40), TextAlignment = UITextAlignment.Center, Font = UIFont.SystemFontOfSize(20), TextColor = UIColor.Gray, Text = "Type Amount" }); _totalField = new UIDecimalField (_amount) { Frame = new RectangleF(50,50,220,40), TextAlignment = UITextAlignment.Center, Font = UIFont.BoldSystemFontOfSize(30), Text = _amount.ToString("N2"), EnablesReturnKeyAutomatically = true, BorderStyle = UITextBorderStyle.RoundedRect, }; View.AddSubview(_totalField); _totalField.BecomeFirstResponder(); }
public override bool ShouldChangeCharacters(UITextField textField, NSRange range, string replacementString) { var newText = textField.Text.Remove(range.Location, range.Length); newText = newText.Insert(range.Location, replacementString); if (newText.Length > 0) { textField.Text = (UIDecimalField.GetAmountFromString(newText)).ToString("N2"); return(false); } return(false); }