Swift-使用drawInRect:withAttributes绘制文本:

Swift-使用drawInRect:withAttributes绘制文本:,第1张

Swift-使用drawInRect:withAttributes绘制文本:

问题在于这

font
是可选的,因为便利构造函数现在返回可选值,因此
font
需要将其解包为字典中的值:

if let actualFont = font {    let textFontAttributes = [        NSFontAttributeName: actualFont,        NSForegroundColorAttributeName: textColor,        NSParagraphStyleAttributeName: textStyle    ]    text.drawInRect(NSOffsetRect(textRect, 0, 1), withAttributes: textFontAttributes)}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5505925.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存