You cannot simply cast one layer as another. In order for a view to have a non-standard layer, you need to subclass it and define the +layerClass
method:
@implementation MyViewSubclass
+ (Class)layerClass {
return [CAEmitterLayer class];
}
...
Unfortunately for your case, the view you're working with has already set up a custom layer, C4Layer
, which can be seen on GitHub. This layer is doing a lot and you don't want to try replacing it.
What you can do is insert your own sublayer into your canvas:
CAEmitterLayer *myLayer = [CAEmitterLayer layer];
myLayer.frame = self.canvas.bounds;
[self.canvas.layer addSublayer:myLayer];
This emitter layer will now overlay your layer and you can add any effects you want. If you want the emitter below other layers, you can use insertSublayer:myLayer atIndex:0
.