如何從UITextField
禁用Swift中的光標?條件 - 當用戶登錄時,然後進入應用程序。如果用戶可以從應用程序註銷,則不會將光標顯示到UITextField中。在swift中禁用UITextField中的閃爍光標?
回答
首先,你需要確認到UITextFieldDelegate然後設置文本框狀yourTextField.delegate =self
添加 yourTextField.resignFirstResponder()
你的代碼。將resignFirstResponder調用到yourTextField。 ,你也可以使用下面的代碼(根據你的需要)。
在委託方法textFieldDidEndEditing(textField: UITextField)
與檢查(如果)它是否有一些值/文本不是。
yourTextField.attributedPlaceholder = NSAttributedString(string: "User Name", attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()]) textUserName.resignFirstResponder()
最初在user default
,當用戶按下退出鍵設置的值作爲NO
爲如
UserDefaults.standard().set(true, forKey: "disalert")
當過你來到這個頁面檢查等作爲
條件設置一些布爾值let disalert: Bool = UserDefaults.standard().bool(forKey: "disalert")
self.youtextField().tintColor = UIColor.blueColor()
if disalert {
self.youtextField().tintColor = UIColor.clearColor()
self.youtextField().resignFirstresponder()
}
當用戶按下登錄按鈕時將用戶默認值設置爲
UserDefaults.standard().set(false, forKey: "disalert")
使用像
(self.youtextField.valueForKey("textInputTraits") as! String)["insertionPointColor"] = UIColor.clearColor()
或設置像
self.youtextField().tintColor = UIColor.clearColor()
self.youtextField()。tintColor = UIColor.clearColor()爲我工作 – Infaz
,如果你只是不想cursor
那麼你可以設置它的tintColor
到clearColor
。在這種情況下,你的textField將被激活。如果你想使它成爲非活動領域,那麼你應該打resignFirstresponder
方法textfield
!
- 1. 禁用UITextField中的閃爍光標?
- 2. 停止iOS中閃爍的UITextField光標
- 3. coderpad.io禁用閃爍光標
- 4. 禁用EditText閃爍光標
- 5. 光標在UITextField中閃爍,但沒有出現鍵盤
- 6. UITextField禁用光標
- 7. 使用SC.Timer閃爍光標
- 8. 停止光標在IDLE中閃爍
- 9. 焦點光標在WPF中閃爍
- 10. 閃光/閃爍UIView
- 11. TextBox光標不閃爍
- 12. 閃爍光標! Cordova/Phonegap IOS
- 13. Android NumberPicker不閃爍光標
- 14. 輸入光標閃爍
- 15. 如何更改NetBeans中的光標(光標)閃爍率?
- 16. selectize.js - 如何禁用選定項目後的閃爍光標?
- 17. 禁用EditText的輸入法,但保持光標閃爍
- 18. 如何在iphone上閃爍(或閃爍)光標?
- 19. Lotus Notes - 光標在掃描收件箱時閃爍/閃爍
- 20. 更好閃爍的閃爍光標模式?
- 21. 關於在ActionScrip3中閃爍的鼠標自定義光標
- 22. 在活動鏈接上閃爍光標
- 23. 停止Excel閃爍鼠標光標
- 24. 計劃返回閃爍的光標
- 25. 光標在jtable中自動閃爍,無需點擊鼠標
- 26. 使UITextField背景閃爍
- 27. 如何關閉Java中的TextArea中的閃爍光標?
- 28. 在Android中使用相機閃光燈閃爍
- 29. 如何在輸入文本中隱藏閃爍的光標?
- 30. 如何在命令窗口中關閉閃爍的光標?
簡單的改變當前的文本框爲'tintColor =的UIColor clearColor]' –
你確認UITextFieldDelegate的色調顏色? –