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 (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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to