How to apply tint color to NSButton (style Inline) cocoa

Viewed 1566

How to apply tint color to NSButton of style inline and visual bordered Below is block of code i am using

Round one is inline button
round one is button

After using the below code

enter image description here

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

how to change only tint of button

Any suggestion would be more helpful.

2 Answers

The isBordered property of button is related with bezelStyle property. You can set different style to check the appearance.

And if you want button image have specific color. Try use the template image and contentTintColor.

let button = NSButton()
button.image = NSImage(named: NSImage.stopProgressFreestandingTemplateName)
button.image?.isTemplate = true
button.bezelStyle = .inline
button.isBordered = false
button.contentTintColor = NSColor.red

demo

Example (Swift):

/// 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
Related