0

我需要在右侧制作带有图标的 NSMenuItem。我最终得到了自定义视图,其中包含 NSVisualEffectView 顶部的 NSTextField 和 NSImageView 以及我用来模仿系统选择的选择材料。NSVisualEffectView 默认是隐藏的。But when the item is selected, my NSVisualEffectView appears on screen and image is drawn with background. 我怎样才能摆脱它?wantLayer = YES 和 backgroundColor = CGColor.clear 没有帮助。提前致谢。

4

1 回答 1

4

您不需要显式添加 NSVisualEffectView 。默认情况下,菜单项具有 NSVisualEffectView 作为 superView。您可以使用该 VisualEffectView 来模仿选择行为。单击此处下载演示项目。

将图像的isTemplate属性设置为 true。它会根据菜单项的外观而改变。

于 2017-04-13T11:40:06.733 回答