如何将色彩应用于NSButton(样式内联)可可

时间:2019-06-27 10:03:45

标签: macos cocoa nsbutton tint

如何将淡色应用于样式inline和视觉样式bordered的NSButton 以下是我正在使用的代码块

第一个是嵌入式按钮
round one is button

使用以下代码后

enter image description here

InlineButton.wantsLayer = YES;
        InlineButton.layer.backgroundColor = [NSColor redColor].CGColor;

如何仅更改按钮的色调

任何建议都会更有帮助。

2 个答案:

答案 0 :(得分:0)

按钮的isBordered属性与bezelStyle属性相关。您可以设置其他样式来检查外观。

如果您希望按钮图像具有特定的颜色。尝试使用模板图片和{​​{1}}。

contentTintColor

demo

答案 1 :(得分:0)

示例(快速):

/// The system window mockup
var layer = self.systemWindowMockupView.layer
layer?.cornerRadius = 6
layer?.backgroundColor = settings.windowBackgroundColor?.cgColor
layer?.masksToBounds = true. // <<<---- This is what you're looking for