All Products
Search
Document Center

Normal input box

Last Updated: May 13, 2021

AUInputBox is a single-line input box that supports the arrangement of a title on the left side and an image button on the right side.

Sample images


API description

 
  1. typedef NS_ENUM(NSInteger, AUInputBoxType)
  2. {
  3. AUInputBoxTypeMobileNumber, // Mobile phone number
  4. AUInputBoxTypeCreditCard, // Credit card
  5. AUInputBoxTypeBankCard, // Debit card
  6. AUInputBoxTypeAmount, // Amount
  7. AUInputBoxTypeIDNumber, // ID card
  8. AUInputBoxTypeNotEmpty, // Not empty
  9. AUInputBoxTypeAlipayAccount, // mPaaS app account
  10. AUInputBoxTypeNone // No authentication
  11. };
  12. typedef enum AUInputBoxStyle
  13. {
  14. AUInputBoxStyleNone, // No background image.
  15. AUInputBoxStyleiOS6, // Rounded background image.
  16. AUInputBoxStyleiOS7 // Non-rounded background image.
  17. } AUInputBoxStyle;
  18. /**
  19. The single-line input box with title text and a button image.
  20. */
  21. @interface AUInputBox : UIView
  22. #pragma mark - AUInputBox property.
  23. // The text input box.
  24. @property(strong, nonatomic) AUTextField *textField;
  25. @property(strong, nonatomic) NSString *textFieldText;
  26. @property(strong, nonatomic) NSString *textFieldFormat;
  27. @property(assign, nonatomic) CGFloat horizontalMargin;
  28. @property(assign, nonatomic) CGFloat textFieldHorizontalMargin;
  29. // The button.
  30. @property(strong, nonatomic) UIButton *iconButton;
  31. @property(assign, nonatomic) BOOL hidesButtonWhileNotEmpty;
  32. @property(assign, nonatomic) BOOL hidesButton;
  33. // The label displayed on the left part of the input box.
  34. @property(nonatomic, readonly) UILabel *titleLabel;
  35. @property(nonatomic, assign) CGFloat titleLabelWidth;
  36. The style, authenticator, background image, and input box type.
  37. @property(assign, nonatomic) AUInputBoxStyle style;
  38. @property(readonly, nonatomic) UIImageView *backgroundImage;
  39. @property(assign, nonatomic) AUInputBoxType inputBoxType;
  40. #pragma mark - The AUInputBox static method.
  41. /**
  42. * Create an input box component.
  43. * @param originY The Y coordinator of the input box.
  44. * @param type The type of the text input box.
  45. * @return The input box component.
  46. */
  47. + (instancetype)inputboxWithOriginY:(CGFloat)originY inputboxType:(AUInputBoxType)type;
  48. /**
  49. * Create an input box component with an icon button.
  50. * @param originY The Y coordinator of the input box.
  51. * @param icon The icon on the button, 44x44.
  52. * @param type The type of the text input box.
  53. * @return The input box component with a button.
  54. */
  55. + (instancetype)inputboxWithOriginY:(CGFloat)originY buttonIcon:(UIImage *)icon inputboxType:(AUInputBoxType)type;
  56. /**
  57. * @return The control height. The default value is 44. The value is 47 for iPhone6 plus.
  58. */
  59. + (float)heightOfControl;
  60. #pragma mark - The AUInputBox instance method.
  61. - (instancetype)initWithFrame:(CGRect)frame inputboxType:(AUInputBoxType)type;
  62. - (void)buildIconButton:(UIImage *)icon;
  63. /**
  64. * Add a space to the text in the specified format.
  65. * @param text The text content.
  66. * @return The text to which a space has been added.
  67. */
  68. - (NSString *)formatText:(NSString *)text;
  69. /**
  70. * Add an icon by using this method for inputBox without any icon specified during the initialization.
  71. * @param icon The icon on the button.
  72. *
  73. */
  74. - (void)setRightButtonIcon:(UIImage *)icon;
  75. /**
  76. * Check the input validity.
  77. */
  78. - (BOOL)checkInputValidity;
  79. /**
  80. * Filter text. Only digits are allowed. The maximum length is specified.
  81. * The parameter is the delegate parameter and the maximum length is specified by maxLength.
  82. */
  83. - (BOOL)shouldChangeRange:(NSRange)range replacementString:(NSString *)string withMaxLength:(int)maxLength;
  84. /**
  85. * Specify the maximum length.
  86. * @maxLength Maximum length, excluding format spaces.
  87. */
  88. - (BOOL)shouldChangeRange:(NSRange)range replacementString:(NSString *)string withFormatStringMaxLength:(int)maxLength;

Code sample

  • Single-line input box
 
  1. AUInputBox *inputBox = [AUInputBox inputboxWithOriginY:startY inputboxType:AUInputBoxTypeNone];
  2. inputBox.titleLabel.text = @"Label";
  3. inputBox.textField.placeholder = @"Please enter text as prompted";
  4. [self.view addSubview:inputBox];
  • Icon
 
  1. AUInputBox *iconInputBox = [AUInputBox inputboxWithOriginY:startY buttonIcon:image inputboxType:AUInputBoxTypeNone];
  2. iconInputBox.titleLabel.text = @"Label";
  3. iconInputBox.textField.placeholder = @"Please enter text as prompted";
  4. [self.view addSubview:iconInputBox];