tttattributedlabel

Specify multiple/conditional link colors in TTTAttributedLabel

六月ゝ 毕业季﹏ 提交于 2020-01-13 09:34:09
问题 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

UILabel: Custom underline color?

喜夏-厌秋 提交于 2019-12-30 04:21:15
问题 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. 回答1: You can do with NSAttributedString as below. NSMutableAttributedString* string = [[NSMutableAttributedString alloc]initWithString:@"you string"]; [string addAttribute

Can't set linkAttributes on TTTAttributedLabel

流过昼夜 提交于 2019-12-25 04:24:27
问题 Using TTTAttributedLabel, with my code: NSString *contentText = @"some text here foo bar"; [self.content setText:contentText afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) { return mutableAttributedString; }]; self.content.linkAttributes = @{ NSForegroundColorAttributeName: [UIColor redColor], NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle] }; NSRange range = [self.content

TTTAttributedLabel can detect links,but can't be pressed correctly

倾然丶 夕夏残阳落幕 提交于 2019-12-23 12:45:42
问题 I am using TTTAttributedLabel to detect links, here is the code I init the label: - (TTTAttributedLabel *)getLinkLabelWithSize:(CGSize)size text:(NSString *)text{ TTTAttributedLabel *linkLabel; linkLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(0, 0, size.width * 1.1, size.height)]; linkLabel.font = [UIFont systemFontOfSize:14.0f]; linkLabel.backgroundColor = [UIColor clearColor]; linkLabel.lineBreakMode = UILineBreakModeWordWrap; linkLabel.numberOfLines = 0; linkLabel

How to set “NSBackgroundColorAttributeName” on TTTAttributedLabel, OHAttributedLabel or SETextView in Swift

心不动则不痛 提交于 2019-12-23 03:07:25
问题 I'm trying to set NSBackgroundColorAttributeName attribute on TTTAttributedLabel , OHAttributedLabel or SETextView , but it's not work. Anyone have any idea? Sample code is followed. class ViewController: UIViewController { @IBOutlet weak var textLabel: UILabel! @IBOutlet weak var ttLabel: TTTAttributedLabel! @IBOutlet weak var ohLabel: OHAttributedLabel! @IBOutlet weak var seTextView: SETextView! override func viewDidLoad() { super.viewDidLoad() var content: String = "This is Test." var text

Clickable link in TTTAttributedLabel with Swift

一个人想着一个人 提交于 2019-12-20 13:06:26
问题 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:/

TTTAttributedLabel : issue detecting links.

拥有回忆 提交于 2019-12-11 00:41:44
问题 I've been having some issues while using TTTAttributedLabel. Sometimes a given URL doesn't get coloured as a link nor does it react to touch. However, this is solved by scrolling down and up, so by making the Cell view re-draw. I've looking at the issues in the project's github, but the ones that seemed related were already closed. 回答1: Well, the fix was to move the .enabledTextCheckingTypes = NSTextCheckingTypeLink; to the awakeFromNib method the custom UITableViewCell. 来源: https:/

Xcode UIAutomation can't interact with TTTAttributedLabel

江枫思渺然 提交于 2019-12-08 00:25:58
问题 I'm trying to write automation scripts for my app and my problem is that Xcode UI Automation just can't see the elements of TTTAttributedLabel class. Getting full elements tree shows no sign of those TTTAttributedLabel elements. I'm using Xcode 6.1.1 回答1: By default TTTAttributedLabel isn't an accessibility element. It works as custom container and provides accessibility for links/phones and other detected data. To change this behaviour subclass TTTAttributedLabel and override methods of

TTTAttributedLabel “Read More >” tail truncation with several attributes possible?

旧时模样 提交于 2019-12-07 18:09:01
问题 TTTAttributedLabel support a custom truncation string via truncationTokenString as well as truncationTokenStringAttributes . However, I am wanting to go a bit further and set several string attributes on the truncation string, including different fonts and colours. This is what I am trying to achieve: The arrow at the end can be achieved using a font icon, so I was thinking of the following string: @"… Read More >" 'HORIZONTAL ELLIPSIS' (U+2026) + Read More + > character from a font .

TTTAttributedLabel “Read More >” tail truncation with several attributes possible?

核能气质少年 提交于 2019-12-05 22:35:26
TTTAttributedLabel support a custom truncation string via truncationTokenString as well as truncationTokenStringAttributes . However, I am wanting to go a bit further and set several string attributes on the truncation string, including different fonts and colours. This is what I am trying to achieve: The arrow at the end can be achieved using a font icon, so I was thinking of the following string: @"… Read More >" 'HORIZONTAL ELLIPSIS' (U+2026) + Read More + > character from a font . Unfortunately TTTAttributedLabel doesn't allow me to set the ranges for various attributes. Does anyone have a