Question

I've got a NSBezierPath that needs to have a semi-transparent fill. When I fill it with a solid color, I get the expected result. However, when filled with a semi-transparent color I get a path with a rounded stroke but an odd, rectangular fill. It looks like:

Rectangular fill

Instead of filling the entire area, I get a filled rectangle inside the stoke with a small, unfilled boarder. I set up my path as follows:

NSBezierPath *menuItem = [NSBezierPath bezierPathWithRoundedRect:menuItemRect xRadius:3 yRadius:3]

[menuItem setLineWidth:4.0];
[menuItem setLineJoinStyle:NSRoundLineJoinStyle];

[[NSColor whiteColor] set];
[menuItem stroke];

[[NSColor colorWithCalibratedRed:0.000 green:0.000 blue:0.000 alpha:0.500] set];
[menuItem fill];

If anyones got any ideas, that would be great.

Thanks

Was it helpful?

Solution

The semi-transparent fill is overlapping with the border as NSBezierPath strokes from the middle of the path which is causing that small border. The white border and the other border should add up to 4 pixels. So to fix this I think you'll need to create another bezier path to prevent the 2 overlapping each other.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top