macrubyhotcocoa

hotcocoa button background colour


I'm working on project which based on macruby and hotcocoa framework. I don't know objective c. In my project I would like to change color of button (NSButton). Do you know how to achieve this using hotcocoa mappers or macruby?


Solution

  • Setting the background color of NSButton is not directly supported. A robust way to create a customized button is to subclass NSButton and override drawRect:. Another way is to customize the button using CALayers.

    layer = CALayer.layer
    layer.backgroundColor = NSColor.orangeColor.CGColor
    button.setLayer layer
    button.setWantsLayer true