Deprecated - A UILabel with #hashtag @handle and links tappable
Clone or download
Sebastian Thiebaud Sebastian Thiebaud
Sebastian Thiebaud and Sebastian Thiebaud Update
Latest commit 1473991 Nov 11, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
STTweetLabel Fix issue with autolayout Jul 24, 2015
STTweetLabelExample Fix test action in scheme Apr 21, 2015
.gitignore Update .gitignore Oct 9, 2013
.travis.yml Update Travis conf Nov 30, 2013
LICENSE LICENSE file Dec 16, 2012 Update Nov 11, 2015
STTweetLabel.podspec Update to 3.1.21 Jul 24, 2015
screenshot.png Update screenshot size Oct 5, 2013

Platform Version CI License

STTweetLabel (not supported anymore)

A custom UILabel for iOS with certain words tappable like Twitter (#Hashtag, @Handle and links).

STTweetLabel screenshot


Please use CocoaPods and include STTweetLabel in your Podfile.

Important: STTweetLabel 3.0 is based on TextKit and is only compatible with iOS 7 and above.


Build and run the project STTweetLabelExample in Xcode to see STTweetLabel in action.

Example Usage

STTweetLabel *tweetLabel = [[STTweetLabel alloc] initWithFrame:CGRectMake(10.0, 60.0, 300.0, 160.0)];
[tweetLabel setText:@"Hi. This is a new tool for @you! Developed by @SebThiebaud for #iPhone #ObjC... and #iOS7 ;-) My GitHub page:"];
[self.view addSubview:tweetLabel];

Don't forget to implement the detectionBlock. Without implementing this block, you won't be able to detect if somebody has clicked on the hashtag, handle or even a link. Blocks are easy. All you need to do is add a few lines of code:

[tweetLabel setDetectionBlock:^(STTweetHotWord hotWord, NSString *string, NSString *protocol, NSRange range) {
    // Do something


  • NSString *text: The text to display.
  • NSArray *validProtocols: All valid protocols for link (by default: @[@"http", @"https"]).
  • BOOL leftToRight: Writing direction (by default: YES).
  • BOOL textSelectable: Allows the user to select the text (by default: YES).
  • UIColor *selectionColor: If BOOL textSelectable is enabled, it's the color of the selection's background (by default: [UIColor colorWithWhite:0.9 alpha:1.0]).
  • NSTextAlignment textAlignment: Text alignment (by default: NSTextAlignmentLeft).


The two following methods refresh the component. That means you should only set the attributes at the initialization of your STTweetLabel instance.

  • -[STTweetLabel setAttributes:(NSDictionary *)attributes]: Dictionary with attributes for all text.
  • -[STTweetLabel setAttributes:(NSDictionary *)attributes hotWord:(STTweetHotWord)hotWord]: Dictionary with attributes for specific STTweetHotWord.
  • -[STTweetLabel suggestedFrameSizeToFitEntireStringConstraintedToWidth:(CGFloat)width: Returns the CGSize calculated for the text submitted.


Inspired by the original Twitter application.


Sebastien Thiebaud


STTweetLabel is available under the MIT license.