ios – 链接TTTAttributedLabel的轻击颜色

我在我的项目中使用了TTTAttributedLabel.我设法通过修改链接属性来更改我创建的任何链接的默认颜色和下划线.
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 documentation,特别是在activeLinkAttributes

activeLinkAttributes

@property (nonatomic,strong) NSDictionary *activeLinkAttributes
Discussion

A dictionary containing the NSAttributedString attributes to be
applied to links when they are in the active state. If nil or an empty
NSDictionary,active links will not be styled. The default active link
style is red and underlined.

Declared In

TTTAttributedLabel.h

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...