我有一个主层, 它有一个遮罩层。
遮罩层还有子图层(用于更改不同遮罩形状内的布局)。
但是掩码子图层对实际屏蔽没有影响。 :(
我可以用遮罩层做些什么吗? 我想在动画中使用它,因此性能也是一个焦点。
掩模层在开始时是全白的,然后我放入较小的黑/灰度内容,我只想看到结果。我可以用一个灰度图像掩盖CALayer吗?
// 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.