【发布时间】:2016-05-10 06:05:53
【问题描述】:
我的问题在理论上与这个问题相似:iOS NSAttributedString on UIButton
我希望将按钮的标题改为:
"带下划线的字符串
一些文字”
这需要以编程方式 100% 快速完成。
我试图通过使用 NSMutableAttributedString 创建带下划线的部分,然后将其附加到其他文本(以换行符开头)来做到这一点。但是,这给了我错误“无法将类型'Void'('aka'()')的值分配给类型'NSMutableAttributedString”
代码如下:
var patientName = NSMutableAttributedString(string:"Patient Name", attributes: underlineAttributes)
var clickforinfomessage = NSMutableAttributedString(string: "\nclick for patient info")
clickforinfomessage = clickforinfomessage.appendAttributedString(patientName)
startVisitButton.setAttributedTitle(clickforinfomessage, forState: .Normal)
【问题讨论】:
-
clickforinfomessage = clickforinfomessage.appendAttributedString(patientName)到clickforinfomessage.appendAttributedString(patientName)。正如错误所说,此方法(appendAttributedString())没有返回。
标签: ios string swift uibutton nsattributedstring