zack
zack

Reputation: 147

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

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.

Upvotes: 3

Views: 2289

Answers (2)

user4096537
user4096537

Reputation:

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

Upvotes: 0

user25917
user25917

Reputation: 987

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

Upvotes: 6

Related Questions