I would like to change the color only of particular substrings (keywords) while the user is typing in a UITextField
.
In the documentation I saw the property textColor
but it does change the color of the entire text string, while I would like to highlight only some keywords.
Is it possible?
The short answer is no.
It's possible if you create your own textfield from scratch using NSAttributedStrings and CATextLayers or Core Text, but this is an incredibly complex and difficult problem.
If you are mirroring what the user types in a preview box of some sort it is possible to create multiple labels or text fields that stay next to each other and have different colors or fonts or whatever. Otherwise, I'm afraid Nick's answer is accurate - within a single textField it ain't happening.
Good luck,
Damien