gpt4 book ai didi

ios - 获取 TTTAttributedLabel 以粗体打印

转载 作者:行者123 更新时间:2023-11-30 13:28:11 25 4
gpt4 key购买 nike

第一次尝试使用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

这就是现在的样子:

enter image description here

但是我不想要蓝色和下划线的字体,我只想得到黑色和粗体的字体。我该怎么做呢?

最佳答案

能够通过以下方式做我想做的事:

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 = self

关于ios - 获取 TTTAttributedLabel 以粗体打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36885974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com