[英]How to make a menubar app look good with “Dark Mode” in Yosemite?
While developing a menubar app, I am having a hard time finding the preferred method for making the app actually look good. 在开发菜单栏应用程序时,我很难找到使应用程序看起来很好的首选方法。 I would have thought that Apple controls would have essentially handled this for the most part, but it appears not.
我原本以为Apple控件基本上会在很大程度上处理这个问题,但看起来并非如此。
What is the preferred method for making sure a menubar app looks good in both light and dark mode? 确保菜单栏应用程序在明暗模式下看起来都很好的首选方法是什么? Am I missing some control functionality that facilitates this more easily or do I need to manually detect the mode and modify controls appropriately?
我是否缺少一些可以更轻松地实现此功能的控制功能,还是需要手动检测模式并适当地修改控件?
I have a menubar app , and I didn't have to do anything to make it look good in the dark theme. 我有一个菜单栏应用程序 ,我没有做任何事情让它在黑暗的主题中看起来很好。
Light theme: 轻主题:
Dark theme: 黑暗主题:
The most important things you need to do are: 您需要做的最重要的事情是:
Use system colors (eg, [NSColor textColor]
, [NSColor textBackgroundColor]
. These automatically adapt with the various themes. See the Color and Typography section of Apple's OS X Human Interface Guidelines. 使用系统颜色(例如,
[NSColor textColor]
, [NSColor textBackgroundColor]
。这些颜色会自动适应各种主题。请参阅Apple OS X人机界面指南的颜色和排版部分。
Use template images. 使用模板图像。 These also adapt to color changes.
这些也适应颜色变化。 See the System-Provided Images section of Apple's OS X Human Interface Guidelines.
请参阅Apple OS X人机界面指南的系统提供的图像部分 。
It's worth noting that Apple has not made it easy to programmatically detect which color theme is running (there are some tricks, but I'm not aware of any sanctioned method). 值得注意的是,Apple并没有简单地以编程方式检测正在运行的颜色主题(有一些技巧,但我不知道任何受制裁的方法)。 My sense is that they've done this intentionally, so developers don't do custom per-theme stuff.
我的感觉是他们故意这样做,所以开发人员不做自定义的每个主题的东西。 Using system colors and template images, you shouldn't have to.
使用系统颜色和模板图像,您不应该这样做。
Update: Sample project here: https://github.com/zpasternack/MenuBarTest 更新:示例项目: https : //github.com/zpasternack/MenuBarTest
Well, you haven't explain (or shown) in what way it looks bad. 好吧,你没有解释(或显示)它看起来很糟糕的方式。 Probably, you are using a normal, non-template image for its icon.
您可能正在使用普通的非模板图像作为其图标。 You should use a template image, which is an image whose only significant part is the alpha mask.
您应该使用模板图像,这是一个图像,其唯一重要的部分是alpha蒙版。 You tell the system that it's a template image either by naming it with a "Template" suffix (eg "FooTemplate.png") or by calling
-setTemplate:
on it. 您可以通过使用“Template”后缀(例如“FooTemplate.png”)或通过调用
-setTemplate:
来告诉系统它是模板图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.