github:RZCarPlateNoTextField (iOS 車牌號(hào) 鍵盤)
iOS 車牌號(hào)鍵盤 對(duì)UITextField封裝一個(gè)專用車牌號(hào)輸入鍵盤
對(duì)鍵盤的inputView做了一個(gè)替換昏兆,輸入項(xiàng)只能選擇輸入車牌號(hào)(仕<帧(或特殊車牌)+數(shù)字字母+特殊漢字)
- RZCarPlateNoTextField 包含兩個(gè)主要使用類
- RZCarPlateNoTextField
- 繼承自UITextField,
- 可設(shè)置是否顯示車牌號(hào)輸入鍵盤
- 最大輸入長(zhǎng)度 (0 不限制長(zhǎng)度)
- rz_regexPlateNoIfYouNeed(block方法) 可自行設(shè)計(jì)車牌號(hào)校驗(yàn)格式兰英,參考[RZCarPlateNoKeyBoardViewModel rz_regexPlateNo:]方法奶卓,我的校驗(yàn)方法不是最好的,只是一個(gè)初步思路。
- rz_textFieldEditingValueChanged 輸入變化之后的回調(diào)
- RZCarPlateNoInputAlertView
- 以ViewController的形式玻孟,alert彈出框樣式輸入車牌號(hào)
- RZCarPlateNoTextField
使用RZCarPlateNoTextField
- pod加入項(xiàng)目
pod 'RZCarPlateNoTextField'
或?qū)㈨?xiàng)目中Core文件夾拖入目標(biāo)項(xiàng)目
- RZCarPlateNoTextField
RZCarPlateNoTextField *textfield = [[RZCarPlateNoTextField alloc] initWithFrame:CGRectMake(10, 100, 300, 50)];
// textfield.backgroundColor = [UIColor colorWithWhite:0.7 alpha:1];
// textfield.rz_maxLength = 0; // 最大輸入長(zhǎng)度 (0 不限制)
// textfield.rz_checkCarPlateNoValue = NO; // 是否需要校驗(yàn)車牌號(hào)輸入規(guī)則
// textfield.rz_regexPlateNoIfYouNeed = ^NSString * _Nonnull(NSString * _Nonnull text) {
// // 你的校驗(yàn)方法,
// return text;
// };
// textfield.rz_textFieldEditingValueChanged = ^(RZCarPlateNoTextField * _Nonnull textField) {
// NSLog(@"輸入變化回調(diào):%@", textField.text);
// };
// [textfield rz_changeKeyBoard:NO]; // 代碼控制顯示字母 (YES:省份)
[self.view addSubview:textfield];
- RZCarPlateNoInputAlertView
[RZCarPlateNoInputAlertView showToVC:self plateNo:@"" title:@"請(qǐng)輸入車牌號(hào)" plateLength:8 complete:^(BOOL isCancel, NSString * _Nonnull plateNo) {
NSLog(@"plateNo:%@", plateNo);
}];
}];