用uitextfield写xxx xxx xxx格式的电话号码输入框
来源:互联网 发布:大数据的应用案例 编辑:程序博客网 时间:2024/05/16 17:49
1.为uitextfield添加点击事件
2.点击事件内容如下
-(void)reformatAsCardNumber:(UITextField *)textField {
NSString *fieldStr = textField.text;
if (_count < textField.text.length) {
//增加
if (_count ==3 || _count ==8) {
NSMutableString *str = [NSMutableStringstringWithFormat:@"%@",textField.text];
[strinsertString:@" "atIndex:_count];
textField.text = str;
}
}elseif (_count > textField.text.length) {
//减少
if (_count ==5 || _count ==10) {
NSMutableString *str = [NSMutableStringstringWithFormat:@"%@",textField.text];
textField.text = [strsubstringToIndex:_count -2];
}
}
_count = textField.text.length;
if (fieldStr.length >12) {
fieldStr = [fieldStrsubstringToIndex:13];
textField.text = fieldStr;
}
}
- 用uitextfield写xxx xxx xxx格式的电话号码输入框
- xxx
- xxx
- xxx
- XXX
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
- XXX
- ALSA声卡驱动七之ASoC架构中的Codec
- javascript判断undefined值
- thinkPHP的include使用
- 5.5 函数值
- const char*, char const*, char*const的区别
- 用uitextfield写xxx xxx xxx格式的电话号码输入框
- 2014/10/23——记一次新生账号注册的问题吧
- 黑马程序猿_C语言之循环结构
- UVa11683 - Laser Sculpture(很有技巧)
- 第二章:理解DispatcherServlet ——深入浅出学Spring Web MVC
- java基础--数组概念
- linq中jion查询
- mybatis源代码分析之datasource包
- 我的异常01