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