Reputation: 49
I want to make clickable some specific text on UILabel
e.g: @"Lorem Ipsum is simply dummy text of the printing bla bla"
In this string "Ipsum,dummy,printing"
should be clickable and also its color should be change. I tried this with TTTAttributedLabel
(custom class) but its only changing the color.
Please give me any useful suggestion.
Upvotes: 0
Views: 2128
Reputation: 12908
Dont use Three20
library now. Use core text based RTLabel
https://github.com/honcheng/RTLabel
RTLabel *html = [[RTLabel alloc]init];
html.delegate = self;
strHTML.text = [NSString stringWithFormat:@" <font face=TrebuchetMS size=%i>Unlimited searches of ICD-10-CM Search apps for iPad, iPhone, and iTouch.\n<a href='%@'><font color=#0094fa>%@</font></a> per month</font>", DESC_FONT, @"m", @"$2.99"];
html.frame = CGRectMake(0, 0, TEXT_WIDTH, ROW_HEIGHT);
[html setLineSpacing:5];
[html setLineBreakMode:RTTextLineBreakModeWordWrapping];
[html setBackgroundColor:[UIColor clearColor]];
[html setText:strHTML];
[html setUserInteractionEnabled:YES];
[self.view addSubview:html];
And here is its delegate method:
- (void)rtLabel:(id)rtLabel didSelectLinkWithURL:(NSURL*)url
{
NSLog(@"%@", url);
}
Your label will look like this:
Upvotes: 1