在NSImage上绘制透明文本

技术

我正在使用以下代码在NSImage上绘制NSString。如何使此文本透明

text.draw(at:  NSZeroPoint, withAttributes: [NSFontAttributeName: font, NSForegroundColorAttributeName: NSColor.white])

如何使该文本透明?

请指教

里奥·达布斯

您可以将NSColor方法与AlphaComponent(_ :)一起使用,并更改其颜色不透明度。

text.draw(at: NSZeroPoint, 
          withAttributes: [NSFontAttributeName: font, 
                           NSForegroundColorAttributeName: NSColor.white.withAlphaComponent(0.5)])

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章