public override void ViewDidLoad() { Title = _title; View.AddSubview(new UILabel { Frame = new CGRect(20, 10, 280, 40), TextAlignment = UITextAlignment.Center, Font = (UIFont)(UIFont.SystemFontOfSize(20)), TextColor = UIColor.Gray, Text = "Type Amount" }); _totalField = new UIDecimalField(_amount) { Frame = new CGRect(50, 50, 220, 40), TextAlignment = UITextAlignment.Center, Font = (UIFont)(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((int)range.Location, (int)range.Length); newText = newText.Insert((int)range.Location, replacementString); if (newText.Length > 0) { textField.Text = (UIDecimalField.GetAmountFromString(newText)).ToString("N2"); return(false); } return(false); }