I have a main layer, that has a mask layer.
The mask layer has also sublayers (to change layouts within resulting different mask shapes).
But the mask sublayers have no effect on the actual masking. :(
Is there something I can do with the mask layer? I want to use it in an animation, so performance also a focus.
The mask layer is full white at start, then I put in smaller black/grayscale content, and I just want to see the result. Can I mask a CALayer with a grayscale image at all?
// Disable layer actions with this delegate object.
self.layerDelegate = [TCLayerDelegate new];
// Create.
CALayer *layer = [CALayer layer];
layer.delegate = self.layerDelegate;
// Setup.
layer.contents = (id)self.colorImage.CGImage; // A simple opaque image with a color.
layer.frame = (CGRect){CGPointZero, self.size};
layer.anchorPoint = (CGPoint){ 0.0, 0.5 };
// Align.
self.layer.position = self.a;
// Create mask.
self.maskLayer = [CALayer layer];
self.maskLayer.delegate = self.layerDelegate;
// Setup.
self.maskLayer.contents = (id)self.maskImage.CGImage; // A black opaque image for now.
self.maskLayer.frame = (CGRect){CGPointZero, self.size};
// Add mask.
self.layer.mask = self.maskLayer;
// Add circles.
[self.circle createLayer]; // This object amongst many other things creates a transparent layer that holds a white circle.
// Add to mask.
[self.maskLayer addSublayer:self.circle.layer];
// Now I'd like to see layer masked with the circle.