I am trying to update the Image of an NSButton(Image) through a toggle in my storyboard. The NSButton Image is not changing though.
Here my ViewController IBAction Code:
@IBAction func ButtonState(_ sender: NSSwitch) {
let stateOfButton = sender.state
if (stateOfButton.rawValue == 1){
testButton.isEnabled = true
}
else{
testButton.isEnabled = false
}
}
Here a snippet from my NSButton Class with the modifications:
override var isEnabled: Bool{
didSet{
if(self.isEnabled){
self.image = NSImage(named: "TestEnabled")
print("TestEnable")
}
else{
self.image = NSImage(named: "TestDisabled")
self.state = NSControl.StateValue(rawValue: 0)
print("NoEnable")
}
}
The print statements are executed on toggling the switch but the image is not changing.