Is it possible for me to implement drawLayer:inContext:
two times, one for each layer?
For example:
CALayer *layer1 = [CALayer layer];
layer1.frame = self.view.frame;
[self.view.layer addSubLayer:layer1];
CALayer *layer2 = [CALayer layer];
layer2.frame = self.view.frame;
[self.view.layer addSubLayer:layer2];
Now that I have two layers (aside from the layer already included in the UIView), I want each layer to implement different "actions" depending on their drawLayer:inContext:
method. So how can I get each layer to perform the specific actions? Should I use performSelector:
? Please give me any tips or advices. Thanks!
I found the solution here. All you have to do is to keep reference of the layer you are currently using. Then use if..else...
or switch statement to perform the actions in drawLayer:inContext:
based on the current layer you are using.