Tag: tttattributedlabel

TTTAttributedLabel可以检测链接,但不能正确按下

我正在使用TTTAttributedLabel来检测链接,这里是我初始化标签的代码: – (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.enabledTextCheckingTypes = NSTextCheckingTypeLink; linkLabel.delegate = self; linkLabel.text = text; return linkLabel; } 我将标签添加到另一个视图(xxxView)。 CGSize size = [str sizeWithFont:fon constrainedToSize:CGSizeMake(150, 40)]; [returnView addSubview:[self getLinkLabelWithSize:size […]

TTTAttributedLabel“阅读更多>”可能有几个属性的尾部截断?

TTTAttributedLabel通过truncationTokenString以及truncationTokenStringAttributes支持一个自定义的截断string。 但是,我想要进一步并在截断string上设置几个string属性,包括不同的字体和颜色。 这是我想要实现的: 最后的箭头可以使用字体图标来实现,所以我想到了下面的string: @"… Read More >" 'HORIZONTAL ELLIPSIS' (U+2026) + > character from a font Read More + > character from a font 。 不幸的是, TTTAttributedLabel不允许我设置各种属性的范围。 有没有人有一个很好的解决scheme,或将不得不手动这样做,基本上计算string,因为它可以在两行,包括@"… Read More >"string。 谢谢!

在TTTAttributedLabel中指定多个/条件链接颜色

我添加了TTTAttributedLabel链接检测器,它标识@mentions和#hashtags,并在TTTAttributedLabel实例中的该位置创build一个链接: – (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 = [match rangeAtIndex:1]; NSString *mentionString = [text substringWithRange:matchRange]; NSRange linkRange = [text rangeOfString:mentionString]; NSString* user = [mentionString substringFromIndex:1]; NSString* linkURLString = [NSString […]

UILabel:自定义下划线颜色?

我需要一个UILabel的文本是黑色的,但在文本下面有一个浅灰色的下划线。 这可能与NSAttributedString或TTTAttributedLabel ? 或者是使用Core Graphics的自定义绘图? 澄清:我需要一个不同的颜色下划线的特定颜色的文字。 例如:红色下划线上的蓝色文字。

链接TTTAttributedLabel的tap颜色

我在我的项目中使用TTTAttributedLabel。 我已经设法改变默认的颜色,并通过修改链接属性来创build任何链接。 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.activeLinkAttributes = pLinkAttributes; 不过,我注意到,当我点击链接时,它会随着任何其他链接点击时瞬间变红。 我需要改变这种颜色。 任何线索怎么可能做?

TTTAttributedLabel链接正在样式化,但不能点击

我一直在寻找解决scheme来获取可点击链接的工作。 当使用UITextView + NSAttributedString时,我可以得到这个工作,但是当它是一个UITableViewCell时,它不会正确地自动布局。 现在我已经将TTTAttributedLabel添加到了我的项目中,并且完美地performance了视图的风格。 链接也变成蓝色,并加下划线。 然而点击他们什么也不做。 我在我的控制器上实现了TTTAttributedLabelDelegate,在故事板中实现了MyLabel(它只是扩展了TTTAttributedLabel,并且具有委托选项,因为我希望它们在同一个函数内激发)中的标签。 现在我已经把控制器设置成了我认为可能无法指向自己的委托。 但是这些函数都没有被解雇,我得到了断点并login了它。 我实现了didSelectLinkWithUrl和didLongPressLinkWithUrl。 func attributedLabel(label: TTTAttributedLabel!, didSelectLinkWithURL url: NSURL!) { Debug.log("link clicked") } func attributedLabel(label: TTTAttributedLabel!, didLongPressLinkWithURL url: NSURL!, atPoint point: CGPoint) { Debug.log("link long clicked") } 出口 @IBOutlet weak var content: MyLabel! MyLabel 导入UIKit导入TTTAttributedLabel class MyLabel : TTTAttributedLabel, TTTAttributedLabelDelegate { override func didMoveToSuperview() { if (self.delegate […]