【发布时间】:2019-11-09 08:03:04
【问题描述】:
如何将色调颜色应用于样式inline 和视觉bordered 的NSButton
下面是我正在使用的代码块
使用以下代码后
InlineButton.wantsLayer = YES;
InlineButton.layer.backgroundColor = [NSColor redColor].CGColor;
如何只改变按钮的色调
任何建议都会更有帮助。
【问题讨论】:
如何将色调颜色应用于样式inline 和视觉bordered 的NSButton
下面是我正在使用的代码块
使用以下代码后
InlineButton.wantsLayer = YES;
InlineButton.layer.backgroundColor = [NSColor redColor].CGColor;
如何只改变按钮的色调
任何建议都会更有帮助。
【问题讨论】:
按钮的isBordered属性与bezelStyle属性相关。您可以设置不同的样式来检查外观。
如果您希望按钮图像具有特定颜色。尝试使用模板图像和contentTintColor。
let button = NSButton()
button.image = NSImage(named: NSImage.stopProgressFreestandingTemplateName)
button.image?.isTemplate = true
button.bezelStyle = .inline
button.isBordered = false
button.contentTintColor = NSColor.red
【讨论】:
示例(斯威夫特):
/// 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
【讨论】: