xcode - Changing background color of NSView in Swift 2.0 -
i trying change background color of nsview , have tried 1 of solution outlined in this answer. however, it's not working me. missing here? should use viewwillappear() here or meant ios?
related code:
class viewcontroller: nsviewcontroller { override func viewdidload() { super.viewdidload() self.view.wantslayer = true } override var representedobject: anyobject? { didset { // update view, if loaded. } } override func awakefromnib() { if self.view.layer != nil { let color : cgcolorref = cgcolorcreategenericrgb(1.0, 0, 0, 1.0) self.view.layer?.backgroundcolor = color } } }
p.s - i'm new os x/ios programming , trying figure way out through documentation , existing solutions. using xcode 7 beta 4.
import cocoa class viewcontroller: nsviewcontroller { override func viewdidload() { super.viewdidload() view.wantslayer = true view.layer?.backgroundcolor = nscolor(red: 1, green: 0, blue: 0, alpha: 1).cgcolor } override var representedobject: anyobject? { didset { } } }
Comments
Post a Comment