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.
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
initially set the some bool value in
user default
, when user press the logout button set the value asNO
for e.g
when ever you comes to this page check the condition like as
when ever user press the login button set the user default value as
use like
or set like
if you just don't want
cursor
then you can set it'stintColor
toclearColor
. In this case your textField will be active. If you want to make it inactive field then you should callresignFirstresponder
method oftextfield
!First you need to confirm to UITextFieldDelegate and then set you textField like
yourTextField.delegate =self
addyourTextField.resignFirstResponder()
to your code. Call resignFirstResponder to yourTextField. and you can also use below code (According to your need).
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()
For Swift 4 that works for me: