我在我的项目中使用了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
DiscussionA 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