Swift 2.1中具有属性的NSAttribute字符串
最近,我更新到了Swift 2.1中具有属性的NSAttribute字符串,swift,nsattributedstring,Swift,Nsattributedstring,最近,我更新到了Xcode 7.0,以下代码在Swift 1.2中运行良好,但在Swift 2.0 let messageString = inString let attributes = [UIFont(): UIFont.systemFontOfSize(15.0)] let attrString:NSAttributedString? = NSAttributedString(string: messageString, attributes: attributes) 有人知道原因吗?
Xcode 7.0
,以下代码在Swift 1.2
中运行良好,但在Swift 2.0
let messageString = inString
let attributes = [UIFont(): UIFont.systemFontOfSize(15.0)]
let attrString:NSAttributedString? = NSAttributedString(string: messageString, attributes: attributes)
有人知道原因吗?用以下方式定义您的属性:
let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(15.0)]
通过以下方式定义属性:
let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(15.0)]