xcode - NSVisualEffectView with rounded corners -


how display nsvisualeffectview with rounded corners in os x?

my code add nsvisualeffectview:

let visualeffectview = nsvisualeffectview(frame: nsmakerect(0, 0, 300, 300)) visualeffectview.material = nsvisualeffectmaterial.dark visualeffectview.blendingmode = nsvisualeffectblendingmode.behindwindow self.addsubview(visualeffectview) 

you can enable layer backed views nsvisualeffectview setting wantslayer true , set cornerradius of backing layer:

    let visualeffectview = nsvisualeffectview(frame: nsmakerect(0, 0, 300, 300))     visualeffectview.material = nsvisualeffectmaterial.dark     visualeffectview.blendingmode = nsvisualeffectblendingmode.behindwindow     visualeffectview.wantslayer = true     visualeffectview.layer?.cornerradius = 15.0     self.view.addsubview(visualeffectview) 

this results in effect view nice rounded corners:

enter image description here


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -