I an using Xcode 11 with IB and I have working some code to change the background colors from a ViewController class. Is there a way to a smiliar thing from the window controller?
Here is the code I have in the ViewController..
import Cocoa
class ViewController: NSViewController {
let colorPanel = NSColorWell()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
@IBAction func changeBKColor(_ sender: NSButton) {
colorPanel.activate(true)
colorPanel.action = #selector(changeColor)
}
@objc func changeColor(_ sender: Any?) {
self.view.layer?.backgroundColor = colorPanel.color.cgColor
}
}