Glen T Glen T - 1 year ago 185
Objective-C Question

Adding an uneditable text suffix to a UITextField

I have a UITextField that I'd like to add a "?" suffix to all text entered.

The user should not be able to remove this "?" or add text to the right hand side of it.

What's the best way to go about this?

Answer Source

You'll probably need to subclass UITextField and override its drawText: method to draw an additional "?" character to the right of the actual text. (Rather than actually add a "?" to the text of the view.