All Products
Search
Document Center

Simplified amount input box

Last Updated: May 25, 2021

The simplified amount input box AUAmountEditTextField can be used together with the amount display component AUAmountLabelText.

AUAmountEditTextField

Currently, the verification and preprocessing logic of input content is not contained, but can be realized by setting delegate in the business.

Sample image

API description

 
  1. NS_ASSUME_NONNULL_BEGIN
  2. @interface AUAmountEditTextField : UITextField
  3. @end
  4. /**
  5. The simplified amount input component with the "¥" symbol and an underscore.
  6. The font size of the input content is scaled with the content length.
  7. */
  8. @interface AUAmountEditText : UIView
  9. /**
  10. The amount input box, you can modify properties or set the delegate as needed.
  11. When a clear event occurs, [amountTextField sendActionsForControlEvents:UIControlEventEditingChanged] is called.
  12. */
  13. @property(nonatomic,strong) AUAmountEditTextField *amountTextField;
  14. /**
  15. It is open to AUAmountLabelText for adjusting the font size when the length of inputText changes.
  16. Business parties do not use.
  17. @param textLength inputText length.
  18. @return UIFont
  19. */
  20. + (UIFont *)resetFontSize:(NSUInteger) textLength;
  21. @end
  22. NS_ASSUME_NONNULL_END
  23. // amountTextField Initialization settings.
  24. _amountTextField.textColor = RGB(0x000000);
  25. _amountTextField.backgroundColor = [UIColor clearColor];
  26. _amountTextField.font = [UIFont fontWithCustomName:kAmountNumberFontName size:45.0];
  27. _amountTextField.contentVerticalAlignment= UIControlContentVerticalAlignmentCenter;
  28. _amountTextField.inputView = [AUNumKeyboards sharedKeyboardWithMode:AUNumKeyboardModeCommon];
  29. _amountTextField.rightViewMode = UITextFieldViewModeWhileEditing;
  30. _amountTextField.rightView = self.rightView;//Use rightView to implement clearButton.

Sample code

 
  1. field = [[AUAmountEditText alloc] init];//Set the width to the screen width and the height to 70.
  2. field.amountTextField.delegate = self;
  3. [view addSubview:field];




AUAmountLabelText

AUAmountLabelText is an amount display component used in conjunction with AUAmountEditTextField.

Sample image

API description

 
  1. NS_ASSUME_NONNULL_BEGIN
  2. /**
  3. The amount display component used in conjunction with the AUAmountEditTextField.
  4. */
  5. @interface AUAmountLabelText : UIView
  6. @property (nonatomic, copy) NSString *amountText;//Amount, without the "¥" symbol, for example, "80.01".
  7. @end
  8. NS_ASSUME_NONNULL_END

Sample code

 
  1. label = [[AUAmountLabelText alloc] init];//Set the width to the screen width and the height to 64.
  2. label.amountText = @"1,345.0";
  3. [view addSubview:label];