0

Hey so i am trying to chnage background of my NSView to a custom color. i looked up a lot of examples and followed them and still didnt exactly achive what i was looking for, So i want to change the bacground color but for somereason it dosent work. here is the code : - import Cocoa

class GoalsVC: NSViewController {

    @IBOutlet weak var topView: NSView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.wantsLayer = true
    }
    override func viewWillAppear() {
        topView.layer?.backgroundColor = NSColor(calibratedRed: 109, green: 188, blue: 99, alpha: 1).cgColor
    }

    override var representedObject: Any? {
        didSet {
            // Update the view, if already loaded.
        }
    }
}

So,line no 3 was supposed to work since if i do this it works :-

topView.layer?.backgroundColor = NSColor.blue.cgColor

So, i might be making a stupid mistake just help me out here. ThankYou

0 Answers0