Vatsal Shukla
Vatsal Shukla

Reputation: 1272

How to change text selection color of UITextField?

Xcode9.2, iOS 11, swift

I'm working on a project where user have to enter some text using Keyboard. User can use English & Japanese keyboard. now, when i start typing using English keyboard it works good no problem at all. but when i change keyboard to Japanese and start entering a same character multiple times. it shows selected text in UITextField.

here is my UITextFieldsetup,

    self.tf.font = self.font
    self.tf.textAlignment = .center
    self.tf.returnKeyType = .done
    self.tf.inputAccessoryView = nil
    self.tf.text = " "
    self.tf.tintColor = UIColor.clear
    self.tf.textColor = UIColor.darkGray

Upvotes: 0

Views: 1838

Answers (1)

ielyamani
ielyamani

Reputation: 18591

To change the text selection color of a UITextField simply change the tint color property:

textField.tintColor = UIColor.purple

Upvotes: 2

Related Questions