Core Animation: Using Layer Masks
Using a mask on a core animation layer is quite easy. This example does the following:
- Creates an NSImage by filling an NSBezierPath.
- Converts the NSImage into a CGImageRef
- Creates three CALayers
- one to show what the mask looks like
- one for the layer that will have
- one for our our mask
Voila!

You can grab the kode here.
Tags: Core Animation
January 19th, 2009 at 3:24 pm
Did you ever figure out if there was a simple way to invert the mask?
Thanks.
-Matt
January 19th, 2009 at 3:29 pm
I never even considered that question. It should be easy enough to do though. Write a function that takes an Image as input. If the pixel is transparent make it solid, and vice versa. Return the resultant image.