快速禁用 UITextField 中的闪烁光标? [英] Disable blinking cursor from UITextField in swift?
问题描述
如何从 UITextField
禁用 Swift 中的光标?条件 - 当用户登录时,然后进入应用程序.如果用户可以让我从应用程序注销,则不会将光标显示到 UITextField 中.
How to disable cursor in Swift from UITextField
? Condition - When the user logs in, then enter into application. If user can may me logout from application then not show cursor into UITextField.
推荐答案
首先你需要确认 UITextFieldDelegate 然后像 yourTextField.delegate =self
一样设置你的 textField添加yourTextField.resignFirstResponder()
First you need to confirm to UITextFieldDelegate and then set you textField like yourTextField.delegate =self
add
yourTextField.resignFirstResponder()
到你的代码.将 resignFirstResponder 调用到 yourTextField.你也可以使用下面的代码(根据你的需要).
to your code. Call resignFirstResponder to yourTextField. and you can also use below code (According to your need).
在委托方法 textFieldDidEndEditing(textField: UITextField)
中检查(如果)它是否具有某些值/文本.
In delegate method textFieldDidEndEditing(textField: UITextField)
with checking (if) whether it has some value/text of not.
yourTextField.attributedPlaceholder = NSAttributedString(string: "User Name", attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()]) textUserName.resignFirstResponder()
这篇关于快速禁用 UITextField 中的闪烁光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!