1

I've added a UITextField so I can type some text in my app. I can type text, and the text is displayed. However, there is no cursor, and so there's no way to tell what you are modifying before modifying it.

Is it an expected behavior ? Is there any way to show the cursor ?

Thanks in advance

Xys
  • 8,486
  • 2
  • 38
  • 56

2 Answers2

13

I think your cursor color is similar to text background color

you can change by this

OBj-C [[UITextField appearance] setTintColor:[UIColor blackColor]];

Swift UITextField.appearance().tintColor = .black

Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35
  • Thanks a lot, it fixed it. However I see that each time I change the cursor position, it goes to the end of the word, not exactly where I clicked. Is this normal ? I know this is another question, but if you have a solution.. – Xys Aug 25 '17 at 12:35
  • Okay, I'm new to iOS. I just needed to long click, and then there is a buble where you can move inside a word. – Xys Aug 25 '17 at 12:37
  • how you change cursor position by the finger or using any code by finger it should move with your finger position as buble appear – Abdelahad Darwish Aug 25 '17 at 12:38
  • I use the tintColor this way in Swift 4 + Xcode 9.2 ==> myTextField.tintColor = .white works fine. I use Mr.Darwish code as sample. – AbuTaareq Feb 28 '18 at 20:51
2

First of all this is not default behavior of UITextField that your are not see cursor BTW

In the viewDidAppear method just write

yourTxtFieldObject.tintColor = [UIColor redColor];
Govaadiyo
  • 5,644
  • 9
  • 43
  • 72