0

以下代码抛出此异常:

*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__SwiftValue renderingMode]:无法识别的选择器发送到实例 0x6000007122b0”

let helloWorld = "Hello World"
let width = helloWorld.size(withAttributes: [.font: Font.system(size: 16.0)])
print("\(width)")

有没有人知道为什么这不起作用或潜在的解决方法?这发生在针对 iOS 13.2 的 Swift 5 中

4

1 回答 1

1

结构Font不同于类UIFont。以下作品。

    let width = helloWorld.size(withAttributes: [.font: UIFont.systemFont(ofSize: 16.0)])
于 2019-11-26T17:33:47.153 回答