Re: CAShapeLayer as a mask for CALayer: rounded corners are stretched
Re: CAShapeLayer as a mask for CALayer: rounded corners are stretched
- Subject: Re: CAShapeLayer as a mask for CALayer: rounded corners are stretched
- From: David Duncan <email@hidden>
- Date: Mon, 24 Oct 2011 10:20:02 -0700
On Oct 21, 2011, at 8:23 PM, Anton Sotkov wrote:
> I want to mask a CALayer with CAShapeLayer, because changes to the shape can be animated.
>
> When I use the CAShapeLayer as a mask, its rounded corners are stretched. However, if I take the same shape, create an image with it, and use the image to mask my CALayer, the rounded corners are perfectly fine.
>
> What am I missing here?
The CAShapeLayer favors performance over accuracy, while Quartz favors accuracy over performance. As such it is entirely possible to get slightly different results between the APIs.
> CALayer *imageBasedMaskLayer = [CALayer layer];
> [imageBasedMaskLayer setContents:(id)[[self maskWithSize:NSMakeSize(50, 50)] CGImageForProposedRect:NULL context:nil hints:nil]];
> [imageBasedMaskLayer setFrame:CGRectMake(0, 0, 50, 50)];
Of note is that on 10.6 or later you can assign an NSImage directly as the contents of a layer, so your CGImageForProposedRect::: call is unnecessary here.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden