//1.创建
lettextfield =UITextField(frame:CGRect(x:50,y:100,width:200,height:40))
textfield.borderStyle= .none
self.view.addSubview(textfield)
//2.设置placeHolder
textfield.placeholder="请输入密码"
//3.文字超过文本框长度,自动缩小字体,且设置最小字体
textfield.adjustsFontSizeToFitWidth=true
textfield.minimumFontSize=14
//4.对齐方式
textfield.textAlignment= .center
//5.设置背景图片
textfield.borderStyle= .none
textfield.background=UIImage(named:"backImg")
//6.右侧的 X 关闭按钮
textfield.clearButtonMode= .always
//7.设置键盘类型
textfield.keyboardType= .numberPad
//8.第一响应者
textfield.becomeFirstResponder()
textfield.resignFirstResponder()
//9.设置代理
textfield.delegate=self;
//10.绑定事件
textfield.addTarget(self, action:#selector(textfieldAction), for: .editingChanged)