Home

Awesome

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

Installation

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.

Demo

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: https://t.co/pQXDoiYA"];
[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
}];

Properties

Methods

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

Credits

Inspired by the original Twitter application.

Contact

Sebastien Thiebaud

License

STTweetLabel is available under the MIT license.