在swift中禁止从UITextField闪烁光标? [英] Disable blinking cursor from UITextField in swift?

查看:330
本文介绍了在swift中禁止从UITextField闪烁光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 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然后设置you textField like yourTextField.delegate = self
add
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:用户名,属性:[NSForegroundColorAttributeName:UIColor.whiteColor()])textUserName.resignFirstResponder()

这篇关于在swift中禁止从UITextField闪烁光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆