首页 > 其他分享 >设置键盘只能输入数字( phoneNumTextField.keyboardType = UIKeyboardTypeNumberPad;)

设置键盘只能输入数字( phoneNumTextField.keyboardType = UIKeyboardTypeNumberPad;)

时间:2023-05-09 16:32:49浏览次数:34  
标签:phoneNumTextField phoneImage keyboardType 40 UIKeyboardTypeNumberPad backgroundC

//手机号码textField
    phoneNumTextField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0,[[UIScreen mainScreen] bounds].size.width, 40)];
    UIView *phoneImage = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    phoneImage.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ico_phone"]];
    phoneNumTextField.leftViewMode = UITextFieldViewModeAlways;
    phoneNumTextField.leftView = phoneImage;
    phoneNumTextField.backgroundColor = [UIColor whiteColor];
    phoneNumTextField.placeholder = @"请输入手机号码";
    phoneNumTextField.font = [UIFont systemFontOfSize:14];
    phoneNumTextField.textAlignment = NSTextAlignmentLeft;
    phoneNumTextField.keyboardType = UIKeyboardTypeNumberPad;
    phoneNumTextField.delegate = self;
    phoneNumTextField.clearButtonMode = UITextFieldViewModeWhileEditing;

标签:phoneNumTextField,phoneImage,keyboardType,40,UIKeyboardTypeNumberPad,backgroundC
From: https://blog.51cto.com/u_16105066/6258912

相关文章