带有Swift 2.1中属性的NSAttributedString

时间:2015-09-19 10:23:05

标签: 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)

谁知道为什么?

1 个答案:

答案 0 :(得分:4)

以这种方式定义属性:

    let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(15.0)]