I am looking for a way to work around the conflict between -[CALayer 
cornerRadius] and +[NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius]. 
These days, NSBezierPath apparently uses a new algorithm to draw rounded 
corners on a rectangle, resulting in a smoother-appearing curve. However, 
various other classes apparently still use an older algorithm and draw rounded 
corners in a slightly different shape. This results in an unsightly graphical 
blemish when the two rounded rectangles are superimposed. The difference is 
illustrated and explained at 
<http://stackoverflow.com/questions/22453095/why-does-applying-a-bezierpathwithroundedrect-mask-yield-a-different-result-from>
 and the included links.

My OS X application has a transparent borderless window. The window's content 
view contains an NSVisualEffectView subview with dark material and a maskImage 
set to give it rounded corners using +[NSBezierPath 
bezierPathWithRoundedRect:xRadius:yRadius]. The NSVisualEffectView in turn 
contains a Core Animation layer-hosting subview whose root layer calls 
-setCornerRadius: before setting its background color. Because of the conflict 
between CALayer and NSBezierPath described above, all four corners of the 
window reveal a thin, curved arc in the dark color of the NSVisualEffectView 
material, because the curve drawn by the Core Animation layer's lighter 
background color has a little different shape.

I have tried every strategy I can think of to eliminate this graphical glitch, 
without success. All of my strategies involve using the same methods to draw 
the corners both in the NSVisualEffectView and the CALayer, on the assumption 
that using a single method for both will result in identical corner shapes. For 
example, I have drawn the corners of the NSVisualEffectView's maskImage using 
CGPathCreateWithRoundedRect(), which, according to lots of Googling, apparently 
does not incorporate the improved NSBezierPath rounded corner algorithm. And I 
have tried adding a CAShapeLayer mask to the subview's root layer using either 
-bezierPathWithRoundRect or CGPathCreateWithRoundedRect() instead of 
-setCornerRadius to round the corners. Nothing has eliminated the unsightly 
sliver at each corner, although -bezierPathWithRoundedRect and 
CGPathCreateWithRoundedRect() both create a slimmer sliver.

Can anyone suggest another approach? Apple's application switcher 
(Command-Tab), which I am trying to imitate, seems to solve the problem. Or 
maybe it takes a completely different approach.

-- 

Bill Cheeseman - b...@cheeseman.name

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to