Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source Library For Easily Creating A UILabel With Clickable Words

  •  
  •  
  •  
  •  
  •  

One question that seems to come up time and time again is how to create tappable words within a UILabel.  Earlier I mentioned an open source project providing a solution, but that project seems to have developed some issues.

Here’s a new library from Sebastian Thibeaud that makes it easy to create tappable words inspired by the Twitter syntax making words prefixed with @ or # clickable along with http links with a very simple callback system that uses the tagged word.  You can also define the colors for the different tags.

Here’s an example given on the Github page of the library in use:

STTweetLabel *tweetLabel = [[STTweetLabel alloc] initWithFrame:CGRectMake(20.0, 60.0, 280.0, 200.0)];

[tweetLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:17.0]];
[tweetLabel setTextColor:[UIColor blackColor]];
[tweetLabel setDelegate:self];
[tweetLabel setText:@"Hi. This is a new tool for @you! Developed by->@SebThiebaud for #iPhone #ObjC... ;-) My GitHub page: https://t.co/pQXDoiYA"];
[self.view addSubview:tweetLabel];

And an image from the demo app with the #ObjC tag clicked:

STTweetLabel

You can find STTweetLabel on Github here.

Looks like a good solution if you’re looking to create tappable words within a UIView.

 


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments