之前在网上查找了一下输入框UITextField只能输入数字的情况,但是在苹果的默认中文键盘下,点击汉字依然可以输入,根据这个需求做了一下研究,一下是自己封装的一个类,是继承UITextField,可直接拿来使用,应用代码如下:
customizeTextField =[[CustomizeTextField alloc] initWithFrame:CGRectMake(100, 100, 150, 60)];
customizeTextField.backgroundColor = [UIColor greenColor];
customizeTextField.limtedSting = @"0123456789.";//定义输入约束限制范围
customizeTextField.pointLocation = 2;//定义小数点后2为
[self.view addSubview:customizeTextField];
此处需要提醒一句:
在您设置customizeTextField.limtedSting