Swift 测量字符串大小

331 阅读1分钟

测量宽度的示例

let tips = "Make this day great!"
let textWidth = tips.size(withAttributes: [.font: UIFont.systemFont(ofSize: 11)]).width