ios – 链接TTTAttributedLabel的轻击颜色

前端之家收集整理的这篇文章主要介绍了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

原文链接:https://www.f2er.com/iOS/336986.html

猜你在找的iOS相关文章