patgdut / STTweetLabel

An UILabel with #hashtag @name http:// tappable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

STTweetLabel

A custom UILabel view controller for iOS with certain words tappable like Twitter (#Hashtag, @People and http://www.link.com/page)

STTweetLabel screenshot

Documentation

You need only 2 files:

  • STTweetLabel.h
  • STTweetLabel.m

Don't forget to implement STLinkProtocol and initialize the STTweetLabel's delegates in the view controller which manages your STTweetLabel (see the example in the project).

You can change the fonts and colors for the different words (#Hashtag/@People AND http://link.com) via the STTweetLabel attributes.

Demo

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

Example Usage

    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];

When an user will click on a tappable word, the delegate methods

- (void)twitterAccountClicked:(NSString *)link;
- (void)twitterHashtagClicked:(NSString *)link;
- (void)websiteClicked:(NSString *)link;

will be called. The word clicked by the user is the parameter (NSString *)link.

Credits

Inspired by the original Twitter applications. Thanks to @TomGiana for disturbing me while I'm focused in my code!

Contact

Sebastien Thiebaud

License

STTweetLabel is available under the MIT license.

About

An UILabel with #hashtag @name http:// tappable

License:MIT License