I want to make clickable some specific text on UILabel
eg: @"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.
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.