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--

enter image description here-

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 - enter image description here

but shadow not appearing, here screen shot - enter image description here.

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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -