-
Notifications
You must be signed in to change notification settings - Fork 36
Home
hsusmita edited this page May 26, 2015
·
29 revisions
A UILabel subclass which responds to touch on specified patterns. It has the following features:
- It can detect pattern specified by regular expression and apply style like font, color etc.
- It allows to replace deafult ellipse with tappable attributed string to mark truncation
- Conveninece methods are provided to detect hashtags, username handler and URLs
#Installation
Add following lines in your pod file
pod 'ResponsiveLabel', '~> 1.0.0'
#Usage
The following snippets explain the usage of public methods. These snippets assume an instance of ResponsiveLabel named "customLabel".
self.customLabel.userInteractionEnabled = YES;
PatternTapResponder hashTagTapAction = ^(NSString *tappedString) {
NSLog(@"HashTag Tapped = %@",tappedString);
};
[self.customLabel enableHashTagDetectionWithAttributes:
@{NSForegroundColorAttributeName:[UIColor redColor], RLTapResponderAttributeName:hashTagTapAction}];
self.customLabel.userInteractionEnabled = YES;
PatternTapResponder userHandleTapAction = ^(NSString *tappedString){
NSLog(@"Username Handler Tapped = %@",tappedString);
}};
[self.customLabel enableUserHandleDetectionWithAttributes:
@{NSForegroundColorAttributeName:[UIColor grayColor],RLTapResponderAttributeName:userHandleTapAction}];