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