Files
CRBoxInputView/PodCode/Classes/CRBoxInputView.h

163 lines
4.4 KiB
C
Raw Normal View History

2019-01-03 18:03:44 +08:00
//
// CRBoxInputView.h
// CRBoxInputView
//
// Created by Chobits on 2019/1/3.
// Copyright © 2019 Chobits. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CRBoxFlowLayout.h"
#import "CRBoxInputCellProperty.h"
2019-01-06 18:59:10 +08:00
#import "CRBoxInputCell.h"
2019-01-03 18:03:44 +08:00
@class CRBoxInputView;
2020-01-20 16:20:36 +08:00
typedef NS_ENUM(NSInteger, CRTextEditStatus) {
CRTextEditStatus_Idle,
CRTextEditStatus_BeginEdit,
CRTextEditStatus_EndEdit,
};
2020-06-10 22:22:52 +08:00
typedef NS_ENUM(NSInteger, CRInputType) {
/// 数字
CRInputType_Number,
/// 普通(不作任何处理)
CRInputType_Normal,
2020-06-11 16:33:26 +08:00
/// 自定义正则此时需要设置customInputRegex
2020-06-10 22:22:52 +08:00
CRInputType_Regex,
};
2019-06-11 12:18:15 +08:00
typedef void(^TextDidChangeblock)(NSString * _Nullable text, BOOL isFinished);
2020-01-20 16:20:36 +08:00
typedef void(^TextEditStatusChangeblock)(CRTextEditStatus editStatus);
2019-01-03 18:03:44 +08:00
@interface CRBoxInputView : UIView
/**
2019-06-11 12:18:15 +08:00
2019-01-09 11:34:31 +08:00
ifNeedCursor
2019-06-11 12:18:15 +08:00
default: YES
2019-01-03 18:03:44 +08:00
*/
@property (assign, nonatomic) BOOL ifNeedCursor;
/**
2019-06-11 12:18:15 +08:00
2019-01-09 11:34:31 +08:00
codeLength
2019-01-03 18:03:44 +08:00
default: 4
*/
2020-06-11 16:33:26 +08:00
@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.
2019-01-03 18:03:44 +08:00
2019-01-03 19:44:13 +08:00
/**
2019-06-11 12:18:15 +08:00
2019-07-19 00:29:24 +08:00
2019-01-09 11:34:31 +08:00
ifNeedSecurity
2019-07-19 00:29:24 +08:00
desc: You can change this property anytime. And the existing texts can be refreshed automatically.
2019-01-03 19:44:13 +08:00
default: NO
*/
@property (assign, nonatomic) BOOL ifNeedSecurity;
/**
2019-06-11 12:18:15 +08:00
securityDelay
desc: show security delay time
2019-01-03 19:44:13 +08:00
default: 0.3
*/
@property (assign, nonatomic) CGFloat securityDelay;
2019-01-07 12:23:58 +08:00
/**
2019-06-11 12:18:15 +08:00
2019-01-09 11:34:31 +08:00
keyBoardType
2019-01-07 12:23:58 +08:00
default: UIKeyboardTypeNumberPad
*/
2019-01-03 19:44:13 +08:00
@property (assign, nonatomic) UIKeyboardType keyBoardType;
2019-01-07 12:23:58 +08:00
2020-06-10 22:22:52 +08:00
/**
inputType
default: CRInputType_Number
*/
@property (assign, nonatomic) CRInputType inputType;
/**
customInputRegex
default: @""
inputType == CRInputType_Regex时才会生效
*/
@property (copy, nonatomic) NSString * _Nullable customInputRegex;
2019-01-10 23:51:17 +08:00
/**
textContentType
2019-06-11 12:18:15 +08:00
: 'nil' 'UITextContentTypeOneTimeCode'
2019-01-10 23:52:50 +08:00
desc: You set this 'nil' or 'UITextContentTypeOneTimeCode' to auto fill verify code.
2019-01-10 23:51:17 +08:00
default: nil
*/
@property (null_unspecified,nonatomic,copy) UITextContentType textContentType NS_AVAILABLE_IOS(10_0);
2019-07-16 14:27:20 +08:00
/**
2019-07-16 15:07:08 +08:00
2019-07-16 14:27:20 +08:00
2019-07-16 15:07:08 +08:00
nil
2019-07-16 14:27:20 +08:00
*/
@property (strong, nonatomic) NSString * _Nullable placeholderText;
2020-01-20 16:34:41 +08:00
/**
codeLength时
default: NO
*/
@property (assign, nonatomic) BOOL ifClearAllInBeginEditing;
2020-06-10 22:22:52 +08:00
2019-06-10 22:39:57 +08:00
@property (copy, nonatomic) TextDidChangeblock _Nullable textDidChangeblock;
2020-01-20 16:20:36 +08:00
@property (copy, nonatomic) TextEditStatusChangeblock _Nullable textEditStatusChangeblock;
2019-06-10 22:39:57 +08:00
@property (strong, nonatomic) CRBoxFlowLayout * _Nullable boxFlowLayout;
@property (strong, nonatomic) CRBoxInputCellProperty * _Nullable customCellProperty;
@property (strong, nonatomic, readonly) NSString * _Nullable textValue;
2019-07-01 11:22:29 +08:00
@property (strong, nonatomic) UIView * _Nullable inputAccessoryView;
2019-01-03 18:03:44 +08:00
2019-06-11 12:18:15 +08:00
/**
desc: Load and prepareView
beginEdit:
default: YES
*/
2019-01-04 16:05:34 +08:00
- (void)loadAndPrepareView;
- (void)loadAndPrepareViewWithBeginEdit:(BOOL)beginEdit;
2020-01-20 16:48:05 +08:00
/**
desc:Reload string. (You can use this function to set deault value)
*/
- (void)reloadInputString:(NSString *_Nullable)value;
2019-06-11 12:18:15 +08:00
/**
desc: Clear all
beginEdit:
default: YES
*/
2019-01-04 16:05:34 +08:00
- (void)clearAll;
- (void)clearAllWithBeginEdit:(BOOL)beginEdit;
2019-06-10 22:39:57 +08:00
- (UICollectionView *_Nullable)mainCollectionView;
2019-01-04 16:05:34 +08:00
2019-06-11 12:18:15 +08:00
// 快速设置
2019-01-04 16:05:34 +08:00
// Qiuck set
2019-06-10 22:39:57 +08:00
- (void)quickSetSecuritySymbol:(NSString *_Nullable)securitySymbol;
2019-01-03 18:03:44 +08:00
2019-06-11 12:18:15 +08:00
// 你可以在继承的子类中调用父类方法
2019-01-09 11:34:31 +08:00
// You can inherit and call super
2019-01-06 19:40:28 +08:00
- (void)initDefaultValue;
2019-06-11 12:18:15 +08:00
// 你可以在继承的子类中重写父类方法
2019-01-09 11:34:31 +08:00
// You can inherit and rewrite
2019-06-11 12:18:15 +08:00
- (UICollectionViewCell *_Nullable)customCollectionView:(UICollectionView *_Nullable)collectionView cellForItemAtIndexPath:(NSIndexPath *_Nullable)indexPath;
2019-01-06 18:59:10 +08:00
2020-06-11 10:04:56 +08:00
// code Length 调整
- (void)resetCodeLength:(NSInteger)codeLength beginEdit:(BOOL)beginEdit;
// Init
- (instancetype _Nullable )initWithCodeLength:(NSInteger)codeLength;
2020-06-10 23:33:44 +08:00
2019-01-03 18:03:44 +08:00
@end