Glen T Glen T - 3 months ago 34
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

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.