Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 2.1中具有属性的NSAttribute字符串_Swift_Nsattributedstring - Fatal编程技术网

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)]