swift – 通过NSAttributedString进行攻击:“没有更多上下文的
发布时间:2020-12-14 04:49:04 所属栏目:百科 来源:网络整理
导读:谁能告诉我什么是错的? let myTitle = NSAttributedString(string: Xdevices[row].deviceName!,attributes: [NSFontAttributeName:UIFont(name: "Georgia",size: 15.0)!,NSForegroundColorAttributeName:UIColor.orangeColor(),NSStrikethroughStyleAttribu
谁能告诉我什么是错的?
let myTitle = NSAttributedString(string: Xdevices[row].deviceName!,attributes: [NSFontAttributeName:UIFont(name: "Georgia",size: 15.0)!,NSForegroundColorAttributeName:UIColor.orangeColor(),NSStrikethroughStyleAttributeName: NSUnderlineStyle.StyleSingle]) 错误是:
插入NSStrikethroughStyleAttributeName:NSUnderlineStyle.StyleSingle后发生这种情况 解决方法
试试这个:
let attributes = [ NSFontAttributeName: UIFont(name: "Georgia",size: 15.0)!,NSForegroundColorAttributeName: UIColor.orangeColor(),NSStrikethroughStyleAttributeName: NSNumber(integer: NSUnderlineStyle.StyleSingle.rawValue) ] let myTitle = NSAttributedString(string: Xdevices[row].deviceName!,attributes: attributes) NSAttributedString(string:attributes :)需要一个类型为[String:AnyObject]的字典.然而,StyleSingle是一个Int.因此,您必须将其包装在NSNumber中. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |