All Products
Search
Document Center

Mobile Platform as a Service:Simplified amount input box

Last Updated:Jul 18, 2023

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

image.png

API description

NS_ASSUME_NONNULL_BEGIN

@interface AUAmountEditTextField : UITextField

@end


/**
  The simplified amount input component with the "¥" symbol and an underscore.
  The font size of the input content is scaled with the content length.
 */
@interface AUAmountEditText : UIView


/**
    The amount input box, you can modify properties or set the delegate as needed.
    When a clear event occurs, [amountTextField sendActionsForControlEvents:UIControlEventEditingChanged] is called.
 */
@property(nonatomic,strong) AUAmountEditTextField *amountTextField;


/**
 It is open to AUAmountLabelText for adjusting the font size when the length of inputText changes.
 Business parties do not use.

 @param textLength inputText length.
 @return UIFont
 */
+ (UIFont *)resetFontSize:(NSUInteger) textLength;

@end

NS_ASSUME_NONNULL_END

// amountTextField Initialization settings.
_amountTextField.textColor = RGB(0x000000);
_amountTextField.backgroundColor = [UIColor clearColor];
_amountTextField.font = [UIFont fontWithCustomName:kAmountNumberFontName size:45.0];
_amountTextField.contentVerticalAlignment= UIControlContentVerticalAlignmentCenter;
_amountTextField.inputView = [AUNumKeyboards sharedKeyboardWithMode:AUNumKeyboardModeCommon];
_amountTextField.rightViewMode = UITextFieldViewModeWhileEditing;
_amountTextField.rightView = self.rightView;//Use rightView to implement clearButton.

Sample code

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


AUAmountLabelText

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

Sample image

API description

NS_ASSUME_NONNULL_BEGIN

/**
 The amount display component used in conjunction with the AUAmountEditTextField.
 */
@interface AUAmountLabelText : UIView

@property (nonatomic, copy) NSString *amountText;//Amount, without the "¥" symbol, for example, "80.01".

@end

NS_ASSUME_NONNULL_END

Sample code

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