第一次尝试使用TTTAttributedLabel框架。我想使用它使我的UILabel的一部分以粗体字体打印,而另一部分则打印为轻量字体:
let messageLabelString = "\(notificationSenderName) would like to rent your \(notificationItem). Approve?"
cell.messageLabel.text = messageLabelString
let nsString = messageLabelString as NSString
let range = nsString.rangeOfString(notificationSenderName)
let url = NSURL(string: "test")
cell.messageLabel.addLinkToURL(url, withRange: range)
cell.messageLabel.delegate = self现在看起来是这样的:

然而,我不想要蓝色和下划线字体,我只是想得到一个黑色和粗体字体。我该怎么做?
发布于 2016-04-27 10:10:55
做了我想做的事:
let messageLabelString = "\(notificationSenderName) would like to rent your \(notificationItem). Approve?"
cell.messageLabel.text = messageLabelString
let nsString = messageLabelString as NSString
let range = nsString.rangeOfString(notificationSenderName)
let url = NSURL(string: "test")
let subscriptionNoticeLinkAttributes = [
NSFontAttributeName: UIFont(name:"JohnstonITCPro-Bold", size:15)!
]
cell.messageLabel.linkAttributes = subscriptionNoticeLinkAttributes
cell.messageLabel.addLinkToURL(url, withRange: range)
cell.messageLabel.delegate = selfhttps://stackoverflow.com/questions/36885974
复制相似问题