osx - rounded corners on NSView using NSBezierPath are drawn badly -


in viewcontroller's main nsview, override func drawrect(dirtyrect: nsrect) method implement rounded corners on main view using nsbezierpath. in same method designate gradient background of main view.

override func drawrect(dirtyrect: nsrect) {      let path: nsbezierpath = nsbezierpath(roundedrect: self.bounds, xradius: 18.0, yradius: 18.0)     path.addclip()     let gradient = nsgradient(startingcolor: nscolor(hexcolorcode: "#383838"), endingcolor: nscolor(hexcolorcode: "#222222"))    gradient.drawinrect(self.frame, angle: 90) } 

the problem arises illustrated in following image:

the image shows 1 of views corners. rounding of corners partially successful, there still remains white corner sticking out beyond window's rounded corners.

if has better method of setting window's corner radius open such suggestions. have done lot of research on matter, solution appears simplest.

any advice on how fix issue appreciated.

you should following on nswindow instance:

[window setopaque:no]; [window setbackgroundcolor:[nscolor clearcolor]]; 

and draw needed shape.

and check this article.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -