I’m trying to show in my app something like this:
Liked by @user1, @user2 and 3 more.
Many apps have this format either for comments like who posted it and their comment,
example: @me yeah apples are good
When you tap their name, it takes you somewhere in the app.
I would like @user1 @user2 and 3 more to be clickable and perform a selector.
I would also like them to be bold and a certain color.
UIWebView can stylize text but can I perform selectors by touching part of an attributed string?
I have been trying to find the best way to do this without making labels and buttons and calculating them dynamically by the length of each username like this:
Label = "Liked by "
Button = "@user1"
Label ", "
Button = "@user2"
Label "and "
Button "3 more"
Label "."
There must be a better way!
Thanks in advance.
You’d be better with an inline UIWebView — provided you don’t need to add this to a scroll view. You can detect actions/link clicks inside a webview by registering some delegate for them and then giving fake protocols/URLs as the link URL. Something like this:
And the delegate method:
EDIT: I found this, exactly what you’re looking for. (as it turns out, @regan also suggested the exact same thing.)