Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source iOS Control: UILabel Replacement With Individually Clickable Words

  •  
  •  
  •  
  •  
  •  

A few days ago I posted a library that takes an image and automatically frames and shadows an image to make it look like a real picture or stack of pictures.  It is just one of those things that you will find yourself probably wanting to do at one time or another.

Another one of those things is making the words clickable in a UILabel.  I’ve seen some very complex suggestions on how to do this voted up on Stackoverflow that will likely just waste a lot of time – so when i came across this component I thought it would be good share.

Here’s a video showing the control in action:

The library is GLTapLabel form German Lallon, and it works simply by calculating the frame size of the words, and turning each into a clickable area.

GLTapLabel is a drop-in replacement for UILabel and includes a delegate (GLTapLabelDelegate.h) and the class that you set as the delegate will receive callbacks including the word that has been tapped (an example is included).

You can find GLTapLabel and the example at the Github repo here.

The default behavior is for GLTapLabel to only make words beginning with the symbols “@” or “#” clickable so if you want to change that behavior like in the video look for the “BOOL hot” variable and remove it’s declaration and the associated if statement.

A nice solution to a common problem.


  •  
  •  
  •  
  •  
  •  

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