tttattributedlabel

Specify multiple/conditional link colors in TTTAttributedLabel

杀马特。学长 韩版系。学妹 提交于 2019-12-05 06:17:29
I've added a link detector to TTTAttributedLabel that identifies @mentions and #hashtags and creates a link at that position in my TTTAttributedLabel instance: - (void)highlightMentionsInString:(NSString *)text withColor:(UIColor *)color isBold:(BOOL)bold isUnderlined:(BOOL)underlined { NSRegularExpression *mentionExpression = [NSRegularExpression regularExpressionWithPattern:@"(?:^|\\s)(@\\w+)" options:NO error:nil]; NSArray *matches = [mentionExpression matchesInString:text options:0 range:NSMakeRange(0, [text length])]; for (NSTextCheckingResult *match in matches) { NSRange matchRange =

TTTAttributedLabel clickable truncation token

£可爱£侵袭症+ 提交于 2019-12-05 04:29:19
问题 I have a TTTAttributedLabel and specified a custom attributed truncation token for it: NSAttributedString *atributedTruncationToken = [[[NSAttributedString alloc] initWithString:@" More..." attributes:@{ NSForegroundColorAttributeName : [UIColor lightGrayColor], NSFontAttributeName : self.messageLabel.font, NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType // no effect }] autorelease]; [self.messageLabel setAttributedTruncationToken:atributedTruncationToken]; It looks perfect, but how

TTTAttributedLabel clickable truncation token

别来无恙 提交于 2019-12-03 20:12:07
I have a TTTAttributedLabel and specified a custom attributed truncation token for it: NSAttributedString *atributedTruncationToken = [[[NSAttributedString alloc] initWithString:@" More..." attributes:@{ NSForegroundColorAttributeName : [UIColor lightGrayColor], NSFontAttributeName : self.messageLabel.font, NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType // no effect }] autorelease]; [self.messageLabel setAttributedTruncationToken:atributedTruncationToken]; It looks perfect, but how can I make the token clickable? (Particularly, I need the label to expand when user clicks on the token,

Clickable link in TTTAttributedLabel with Swift

一世执手 提交于 2019-12-03 13:18:41
I want to make a UILabel with some text with a click-able links in it. Not links to webpages but to actions like I do with an UIButton . So I used TTTAttributedLabel which is working perfectly with Objective C . Now I want to do the same in Swift , so I wrote the below code: self.someLabel.text = NSLocalizedString("Lost? Learn more.", comment: "") let range = self.someLabel.text!.rangeOfString(NSLocalizedString("Learn more", comment:"")) self.someLabel.addLinkToURL (NSURL(string:"action://Learn more"), withRange:NSRange (range)) However, I cannot make the link work in Swift . I am getting the

Link tap color for TTTAttributedLabel

本秂侑毒 提交于 2019-12-03 09:38:44
问题 I am using a TTTAttributedLabel in my project. I have managed to change the default color and underlining for any link that I create by modifying the link attributes. NSArray *pKeys = [[NSArray alloc] initWithObjects:(id)kCTForegroundColorAttributeName, (id)kCTUnderlineStyleAttributeName , nil]; NSArray *pObjects = [[NSArray alloc] initWithObjects:pAlertColor,[NSNumber numberWithInt: kCTUnderlineStyleNone], nil]; NSDictionary *pLinkAttributes = [[NSDictionary alloc] initWithObjects:pObjects

TTTAttributedLabel Delegate didSelectLinkWithURL is not getting called in iPhone

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is my code, whenever I click the link didSelectLinkWithURL delegate is not getting called. Any help is appreciated. TTTAttributedLabel *tttLabel = [[TTTAttributedLabel alloc]initWithFrame:CGRectMake(10, 10, 200, 200)]; NSString *labelText = @"Lost? Learn more."; tttLabel.text = labelText; NSRange r = [labelText rangeOfString:@"Learn more"]; [tttLabel addLinkToURL:[NSURL URLWithString:@"action://show-help"] withRange:r]; [self.view addSubview:tttLabel]; tttLabel.userInteractionEnabled=YES; - (void)attributedLabel:(TTTAttributedLabel *

Link tap color for TTTAttributedLabel

时光怂恿深爱的人放手 提交于 2019-12-02 22:42:50
I am using a TTTAttributedLabel in my project. I have managed to change the default color and underlining for any link that I create by modifying the link attributes. NSArray *pKeys = [[NSArray alloc] initWithObjects:(id)kCTForegroundColorAttributeName, (id)kCTUnderlineStyleAttributeName , nil]; NSArray *pObjects = [[NSArray alloc] initWithObjects:pAlertColor,[NSNumber numberWithInt: kCTUnderlineStyleNone], nil]; NSDictionary *pLinkAttributes = [[NSDictionary alloc] initWithObjects:pObjects forKeys:pKeys]; self.alertMessage.linkAttributes = pLinkAttributes; self.alertMessage

how do I detect and make clickable links in a UILabel NOT using UITextView

送分小仙女□ 提交于 2019-12-01 00:24:04
问题 I am building a chat app and for performance reasons I need to use UILabel's instead of UITextView's to display the chat messages. I have previously used TextView's but with data detection on the scrolling is very slow and choppy. The problem is there is currently no link/phone/address etc... detection for UILabels. How can I know where a link or phone number exists in a string, and then highlight and make it clickable within a UILabel? I have read many articles on how to add attributes for

UILabel: Custom underline color?

眉间皱痕 提交于 2019-11-30 12:42:50
I need the text of a UILabel to be black, but have a light gray underline under the text. Is this possible with NSAttributedString or TTTAttributedLabel ? Or is custom drawing using Core Graphics needed? CLARIFICATION: I need a specific color text on a different color underline. Example: blue text on red underline. Mani You can do with NSAttributedString as below. NSMutableAttributedString* string = [[NSMutableAttributedString alloc]initWithString:@"you string"]; [string addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, string.length)]; [string addAttribute

TTTAttributedLabel links are being styled but not clickable

北城余情 提交于 2019-11-30 09:52:13
I've been looking into a solution to getting clickable links working. I can get this working when using UITextView + NSAttributedString but it just doesn't autolayout properly when it's a UITableViewCell. Now I've added the TTTAttributedLabel to my project and it styles the views just perfectly. The links also turn blue and are underlined. However clicking them does nothing. I did implement TTTAttributedLabelDelegate on my controller, made the label in the storyboard implement MyLabel (Which just extends TTTAttributedLabel and has the delegate options since I want them to fire inside the same