Reputation:
I'm working on an iOS app using swift. I have a SearchBar/Textview (i've tried with both) and want to split each search term a user types in, into a bubble similar to pinterest where the user can later press the cross to remove certain ones.
How do I start with this? I can only seem to change the background of the whole TextField instead of just for each word.
Here's a sample of what I am trying to achieve.
Upvotes: 1
Views: 513
Reputation: 130122
This is not really a formatted text. What they are doing is different. When a space/enter is typed in (and you can detect that by the UITextField
delegate), you take the currently written text and create a view from it.
The structure of that view will be similar to the following:
+ view
+ label with the text
+ x (remove) button
You will then add this view to a container view. The purpose of this view is to keep the search term views in a list.
You can then assign this container view to [UITextField leftView]
.
Of course, then you have to handle removal, backspace etc.
Upvotes: 1