使用模板图像的 HUD 按钮
我正在我的应用程序中构建一个半透明浮动 HUD 窗口,其目的是看起来像“快速查看 HUD”窗口,特别是使用“进入/退出”全屏图像。 Cocoa 提供了 NSEnterFullScreenTemplate (和 NSExitFullScreenTemplate)模板,它可以用于此目的,并且可以在有边框的按钮上正常工作。
但是,一旦我删除边框并将按钮放在深色背景上,它就会保持深灰色,并且很难看到。我想把它变成白色,就像快速查看一样。有没有内置的方法可以做到这一点,或者我是否必须自己缩放和着色图像?
I'm building a semi-transparent floating HUD window in my application, which is intended to look like the Quick Look HUD window, specifically using the Enter/Exit full screen image. Cocoa provides the NSEnterFullScreenTemplate (and NSExitFullScreenTemplate) templates, which serve this purpose, and work fine on bordered buttons.
As soon as I remove the border and put the button on a dark background though, it keeps a dark gray color, and makes it difficult to see. I'd like to make it white, like in Quick Look. Is there a built-in way to do this, or do I have to resort to scaling and coloring the image myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终编写了一个 NSImage 类别类方法,该方法返回所需尺寸和所需颜色的模板图像(基本上是我自己做的,因为我不认为 API 确实提供了执行此操作的方法)。
I ended up writing an NSImage category class method that returns a template image at the desired size and in the desired color (basically doing it myself, as I don't think the API does provide a way to do this).
NSBackgroundStyleDark
背景是深色的。
浅色内容与深色背景形成鲜明对比。
NSBackgroundStyleDark
The background is a dark color.
Light contents contrast well with the dark background.