I'm wondering about changing the color of the cursor / caret in a UITextField
(And UITextView
if its the same answer) in iOS. I've seen answers for OSX development, but nothing for iOS.
Is this even possible?
I'm wondering about changing the color of the cursor / caret in a UITextField
(And UITextView
if its the same answer) in iOS. I've seen answers for OSX development, but nothing for iOS.
Is this even possible?
It works if you set it in code, 'cos somehow color trigger doesn't do it in the Interface Builder (Xcode 6.1.1). It suited well without a need to change any appearance proxy.
With iOS7 you can simply change tintColor of the textField
Setting
tintColor
forUITextField
andUITextView
works differently. While forUITextField
you don't need to call additional code after updatingtintColor
to change cursor color, but forUITextView
you need.So after setting
tintColor
forUITextView
(it doesn't matter in IB or in code) you need to calltextView.tintColorDidChange()
in order to apply it (actually it will pass text view's config down to its subviews hierarchy).It is only possible by accessing a private property and therefore may cause an Apple AppStore app rejection.
take a look at this Stackoverflow question
Swift 3:
A more general approach would be to set the UIView's appearance's tintColor.
Makes sense if you're using many default UI elements.