// // YMCaptchaTextView.h // MSYOUPAI // // Created by YoMi on 2023/5/5. // #import #import "YMCaptchaTextFlowLayout.h" #import "YMCaptchaTextCell.h" #import "YMCaptchaTextCellProperty.h" @class YMCaptchaTextView; typedef NS_ENUM(NSInteger, YMCaptchaTextEditStatus) { YMCaptchaTextEditStatus_Idle, YMCaptchaTextEditStatus_BeginEdit, YMCaptchaTextEditStatus_EndEdit, }; typedef NS_ENUM(NSInteger, YMCaptchaTextType) { /// 数字 YMCaptchaTextType_Number, /// 普通(不作任何处理) YMCaptchaTextType_Normal, /// 自定义正则(此时需要设置customInputRegex) YMCaptchaTextType_Regex, }; typedef void(^TextDidChangeblock)(NSString * _Nullable text, BOOL isFinished); typedef void(^TextEditStatusChangeblock)(YMCaptchaTextEditStatus editStatus); typedef NSString *_Nullable(^TextCustomProcessblock)(NSString * _Nullable text); @interface YMCaptchaTextView : UIView /** 是否需要光标 ifNeedCursor default: YES */ @property (nonatomic, assign) BOOL ifNeedCursor; /** 验证码长度 codeLength default: 4 */ @property (nonatomic, assign, readonly) NSInteger codeLength; //If you want to set codeLength, please use `- (instancetype)initWithCodeLength:(NSInteger)codeLength, or - (void)resetCodeLength:(NSInteger)codeLength beginEdit:(BOOL)beginEdit` in CRBoxInputView. /** 是否开启密文模式 描述:你可以在任何时候修改该属性,并且已经存在的文字会自动刷新。 ifNeedSecurity desc: You can change this property anytime. And the existing texts can be refreshed automatically. default: NO */ @property (nonatomic, assign) BOOL ifNeedSecurity; /** 显示密文的延时时间 securityDelay desc: show security delay time default: 0.3 */ @property (nonatomic, assign) CGFloat securityDelay; /** 键盘类型 keyBoardType default: UIKeyboardTypeNumberPad */ @property (nonatomic, assign) UIKeyboardType keyBoardType; /** 输入样式 TextType default: YMCaptchaTextType_Number */ @property (nonatomic, assign) YMCaptchaTextType textType; /** 自定义正则匹配输入内容 customInputRegex default: @"" 当inputType == YMCaptchaTextType_Regex时才会生效 */ @property (nonatomic, copy) NSString * _Nullable customInputRegex; /** textContentType 描述: 你可以设置为 'nil' 或者 'UITextContentTypeOneTimeCode' 来自动获取短信验证码 desc: You set this 'nil' or 'UITextContentTypeOneTimeCode' to auto fill verify code. default: nil */ @property (null_unspecified, nonatomic, copy) UITextContentType textContentType NS_AVAILABLE_IOS(10_0); /** 占位字符填充值 说明:在对应的输入框没有内容时,会显示该值。 默认:nil */ @property (nonatomic, strong) NSString * _Nullable placeholderText; /** 弹出键盘时,是否清空所有输入 只有在输入的字数等于codeLength时,生效 default: NO */ @property (nonatomic, assign) BOOL ifClearAllInBeginEditing; @property (nonatomic, copy) TextDidChangeblock _Nullable textDidChangeblock; @property (nonatomic, copy) TextEditStatusChangeblock _Nullable textEditStatusChangeblock; /// 文本自定义处理 @property (nonatomic, copy) TextCustomProcessblock _Nullable textCustomProcessblock; @property (nonatomic, strong) YMCaptchaTextFlowLayout * _Nullable captchaTextFlowLayout; @property (nonatomic, strong) YMCaptchaTextCellProperty * _Nullable customCellProperty; @property (nonatomic, strong) UIView * _Nullable inputAccessoryView; @property (nonatomic, strong, readonly) NSString * _Nullable textValue; /** 装载数据和准备界面 desc: Load and prepareView beginEdit: 自动开启编辑模式 default: YES */ - (void)loadAndPrepareView; - (void)loadAndPrepareViewWithBeginEdit:(BOOL)beginEdit; /** 重载输入的数据(用来设置预设数据) desc:Reload string. (You can use this function to set deault value) */ - (void)reloadInputString:(NSString *_Nullable)value; /** 清空输入 desc: Clear all beginEdit: 自动开启编辑模式 default: YES */ - (void)clearAll; - (void)clearAllWithBeginEdit:(BOOL)beginEdit; - (UICollectionView *_Nullable)mainCollectionView; // 快速设置 // Qiuck set - (void)quickSetSecuritySymbol:(NSString *_Nullable)securitySymbol; // 你可以在继承的子类中调用父类方法 // You can inherit and call super - (void)initDefaultValue; // 你可以在继承的子类中重写父类方法 // You can inherit and rewrite - (UICollectionViewCell *_Nullable)customCollectionView:(UICollectionView *_Nullable)collectionView cellForItemAtIndexPath:(NSIndexPath *_Nullable)indexPath; // code Length 调整 - (void)resetCodeLength:(NSInteger)codeLength beginEdit:(BOOL)beginEdit; // Init - (instancetype _Nullable )initWithCodeLength:(NSInteger)codeLength; @end