osx - How to display shadow for NSView? -
i have gone through many threads here , other blogs not able solve issue. have added subview in content view of window. here storyboard--
i have dragged out outlet of customview view controller , here code view controller -
import cocoa import quartzcore class viewcontroller: nsviewcontroller { @iboutlet weak var customview: nsview! override func viewdidload() { super.viewdidload() // additional setup after loading view. self.view.wantslayer = true self.customview.wantslayer = true self.customview.layer?.backgroundcolor = nscolor.redcolor().cgcolor self.customview.layer?.cornerradius = 5.0 self.customview.layer?.shadowopacity = 1.0 self.customview.layer?.shadowcolor = nscolor.blackcolor().cgcolor self.customview.layer?.shadowoffset = nsmakesize(0, -3) self.customview.layer?.shadowradius = 20 } override var representedobject: anyobject? { didset { // update view, if loaded. } } }
i have added quartzcore frame work in project -
but shadow not appearing, here screen shot - .
i not able solve appears trivial. missing? help.
if add following line solves problem-
self.customview.shadow = nsshadow()
final code -
import cocoa import quartzcore class viewcontroller: nsviewcontroller { @iboutlet weak var customview: nsview! override func viewdidload() { super.viewdidload() // additional setup after loading view. self.view.wantslayer = true self.view.superview?.wantslayer = true self.customview.wantslayer = true self.customview.shadow = nsshadow() self.customview.layer?.backgroundcolor = nscolor.redcolor().cgcolor self.customview.layer?.cornerradius = 5.0 self.customview.layer?.shadowopacity = 1.0 self.customview.layer?.shadowcolor = nscolor.greencolor().cgcolor self.customview.layer?.shadowoffset = nsmakesize(0, 0) self.customview.layer?.shadowradius = 20 } override var representedobject: anyobject? { didset { // update view, if loaded. } } }
i not able identify issue may here point out.
Comments
Post a Comment