2

I want to create a custom input view, some of whose buttons insert "icons" into the selected UITextField, like the "RSS" or "Reader" icons which sometimes appear on the right hand side of the URL input field in Mobile Safari. I want the icons to be intermingled with the text and for all intents and purposes (like selection, cut and paste and deletion) behave like normal character glyphs.

Is there a name for these icons? Is there an API for creating them or do I have to build this entirely from scratch?

Robert Atkins
  • 23,528
  • 15
  • 68
  • 97

2 Answers2

10

The leftView and rightView properties (instances of UIView) of the UITextField class are exactly for this purpose, and you can control their behaviour using the leftViewMode and rightViewMode properties. I suggest you to read the UITextField class reference for further details.

  • This is a good start but not exactly what I'm after—my application requires these icons to be intermingled with the text in the UITextField, not strictly on the left or right. – Robert Atkins Dec 12 '11 at 00:51
1

According to this question, what I want is an NSTokenField and there's not one available in stock iOS. However, there are some implementations on GitHub.

Community
  • 1
  • 1
Robert Atkins
  • 23,528
  • 15
  • 68
  • 97