【问题标题】:WatchKit : Attributed string 'String ' contains NSFontAttributeName that isn't a UIFont (SanFranciscoDisplay-Light). RemovedWatchKit:属性字符串“String”包含不是 UIFont (SanFranciscoDisplay-Light) 的 NSFontAttributeName。已移除
【发布时间】:2015-05-05 23:06:48
【问题描述】:

我收到以下错误

属性字符串 'String' 包含的 NSFontAttributeName 不是 UIFont (SanFranciscoDisplay-Light)。已移除

这对我来说没有任何意义,因为根据这个它应该是有效的字体。 http://iosfonts.com。这是我的代码。

 atrString = NSAttributedString(string: atrString.string, attributes:
            [NSForegroundColorAttributeName: UIColor.lightGrayColor(),
                NSFontAttributeName:"SanFranciscoDisplay-Light"])

我正在尝试从我的手表套件代码中访问 San Francisco 字体。任何提示或建议表示赞赏。

【问题讨论】:

  • 您是否检查过该字体和样式的字符串名称是否正确?
  • 我转到上面的链接并输入了完全相同的字体。

标签: ios swift fonts watchkit


【解决方案1】:

NSFontAttributeName 是一个应该包含UIFont 类型值的键。

试试UIFont(name: "SanFranciscoDisplay-Light", size: 25),大小是你想要的任何字体大小。

atrString = NSAttributedString(string: atrString.string, attributes: [NSForegroundColorAttributeName: UIColor.lightGrayColor(), NSFontAttributeName:UIFont(name: "SanFranciscoDisplay-Light", size: 25)])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-16
    • 1970-01-01
    • 2022-01-04
    • 1970-01-01
    • 2014-09-11
    相关资源
    最近更新 更多