首页 > 编程知识 正文

Checkbox,下拉列表框

时间:2023-05-06 12:47:10 阅读:136438 作者:4286

图形页面由StoryBoard拖动文本字段&; 已经实现了放下。 一般属性设定如下。

Text: Plain (普通文本(Attributed )富文本) ) ) ) ) ) ) ) )。

Color:输入的文本颜色

在Font:中输入的文本字体大小

对齐:文本对齐模式、左对齐、右对齐、中心对齐、齐行两端对齐、自然对齐

Placeholder:占位符文本

BackgRound:可以设置背景图像,但如果Border Style设置为round,则无法设置背景图像

DisabledBackground :不可用的状态(textField.enabled=NO; 的背景图像。 注:如果未设置背景值,则此值无效

Border: None无边框; 线线框; Bezel上框和左框变重; 回圈

Clear Button:文本清除按钮Never appears不显示; 有文本输入时,Appears while editing会显示清除按钮,done整理键盘时会消失。 有文本输入时不显示Appears unless editing,在输入完成、done整理键盘之前不显示; is always visible在用户输入文本后一直存在。 即使选择done收纳键盘也显示。 除非选择清除键清空所有文本,否则不会消失。

Capitalization:是大写字母,All Characters全部是大写字母; 将Sentences语句的首字母大写将Words单词的首字母大写; None不怎么写

如果是或默认值为YES,则输入的单词错误时,Correction:会在输入完成后自动修复为正确的单词。 如果为否,输入错误也不会被纠正,输入什么是什么

Smart Dashes:智能破折号的配置状态

在Spell Checking:中启用拼写检查时,文本对象会为所有拼写错误的单词生成红色下划线。 当用户单击拼写错误的单词时,文本对象会向用户呈现可修改的列表。

KeyBoard Type:键盘类型

Default指定当前输入法的默认键盘。 ASCIICapable指定显示标准ASCII字符的键盘。 NumbersAndPunctuation指定数字和标点符号的键盘。 URL指定针对URL输入而优化的键盘。 此键盘类型的特征在于周期“.”和斜线“/”的字符以及“.com”的字符串。 NumberPad指定用于PIN输入的数字键盘。 该键盘类型0通过强调数字9。 此键盘类型不支持自动大写。 PhonePad指定用于输入电话号码的键盘。 对于该键盘类型,数字9以及“*”和“#”字符中的0非常明显。 此键盘类型不支持自动大写。 NamePhonePad指定用于输入个人姓名和电话号码的小键盘。 此键盘类型不支持自动大写。 将EmailAddress指定为输入电子邮件地址的优化键盘。 此键盘类型突出显示了at ()、句点()和空格字符。 DecimalPad指定包含数字和小数点的键盘。 Twitter指定Twitter文本输入的优化键盘,并提供对at () )、hash )和(# )字符的轻松访问。 WebSearch指定用于输入web搜索单词和网址的优化键盘。 此类型的键盘将突出显示空格和句点“.”字符。 ASCIICapableNumberPad指定仅输出ASCII数字的数字键盘。 Alphabet指定针对字符输入而优化的键盘。

keyboard look:键盘整体外观色调Dark深色; 灯光

返回密钥:返回密钥类型

Default指定Return键的可显示标题为“Return”。 Go指定返回键的可视标题为“Go”。 谷歌指定返回键的可视标题是“谷歌”。 Join指定返回键的可显示标题为“Join”。 Next指定返回键的可显示标题为“Next”。 Route指定返回键的可显示标题为“路由”。 Search指定返回键的显示标题为“检索”。 Send指定返回键的可视标题为“发送”。 雅虎指定返回键的可视标题为“雅虎”。 Done指定返回键的可视标题为“完成”。 EmergencyCall指定返回键的可视标题为“紧急呼叫”。 Continue指定返回键的可显示标题为“继续”。 代码实现func addTextField ()//初始化控件let textField=UITextField ) self.view.addsubview(textfield )/代理textfield.delegatation约束textfield.translatesautoresizingmaskintoconstraints=falselettopconstrain=nslayoutconstraint

m: textField, attribute: .top, relatedBy: .equal, toItem: self.view, attribute: .top, multiplier: 1.0, constant: 400) let leftConstrain = NSLayoutConstraint.init(item: textField, attribute: .leading, relatedBy: .equal, toItem: self.view, attribute: .leading, multiplier: 1.0, constant: 20) let rightConstrain = NSLayoutConstraint.init(item: textField, attribute: .trailing, relatedBy: .equal, toItem: self.view, attribute: .trailing, multiplier: 1.0, constant: -20) self.view.addConstraints([topConstrain,leftConstrain,rightConstrain]) //设置输入文本颜色 textField.textColor = UIColor.init(displayP3Red: 23/255, green: 67/255, blue: 89/255, alpha: 1.0) //设置输入字体文本大小 textField.font = UIFont.systemFont(ofSize: 20) //设置输入文本对齐方式 NSTextAlignment->.center .left .right textField.textAlignment = NSTextAlignment.center //设置占位文本 textField.placeholder = "文本输入测试" //设置背景图片 textField.background = UIImage.init(named: "textfieldbg.png") //设置不可点击状态下的背景图片 textField.disabledBackground = UIImage.init(named: "disabletextfieldbg.png") //设置边框 BorderStyle -> .line .none .bezel .roundedRect textField.borderStyle = .line //设置clearbutton展示类型 ViewMode ->.whileEditing .never .unlessEditing .always textField.clearButtonMode = .whileEditing //设置大写规则 UITextAutocapitalizationType ->.allCharacters .none .words .sentences textField.autocapitalizationType = .allCharacters //设置文本纠正 UITextAutocorrectionType -> .yes .no .default textField.autocorrectionType = .yes //设置智能短划线配置状态 UITextSmartDashesType -> .yes .no .default textField.smartDashesType = .yes //设置拼写检查 UITextSpellCheckingType -> .yes .no .default textField.spellCheckingType = .yes //设置键盘类型 UIKeyboardType textField.keyboardType = .emailAddress //设置return key类型 UIReturnKeyType textField.returnKeyType = .done } 常用代理 //return按钮被点击 called when 'return' key pressed. return NO to ignore. func textFieldShouldReturn(_ textField: UITextField) -> Bool { //这里判断当前的textfield是哪一个,可以实现在选择完成按钮或者enter键后切换到下一个textfiled if textField == self.nameTextField { self.nameTextField.resignFirstResponder() self.testTextField.becomeFirstResponder() } else { self.testTextField.resignFirstResponder() self.nameTextField.becomeFirstResponder() } return true } // may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called func textFieldDidEndEditing(_ textField: UITextField) { mealNameLabel.text = textField.text } // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end //选择done后首先触发此方法 func textFieldShouldEndEditing(_ textField: UITextField) -> Bool { return true } // return NO to disallow editing. 光标选中textfield会触发这个事件 func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { return true } // became first responder textfield的键盘弹出 func textFieldDidBeginEditing(_ textField: UITextField) { } // if implemented, called in place of textFieldDidEndEditing:选择done完成输入 func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) { } //return NO to not change text,有文本输入时 func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { return true } // called when clear button pressed. return NO to ignore (no notifications) func textFieldShouldClear(_ textField: UITextField) -> Bool { return true }

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。