Hi, I'm trying to make use of CALayers to create a 3D style effect in one of my applications. However, it seems that nested CALayers do not have perspective applied to them.
To illustrate with pseudo-code, if I have a layer with perspective applied like so:
CATransform3D subLayerTransform = CATransform3DIdentity;
/* set perspective */
subLayerTransform.m34 = -0.002;
superLayer.sublayerTransform = subLayerTransform;
add then add a layer to it like so:
CALayer *sublayer = [CALayer layer];
sublayer.frame = layerFrame;
sublayer.contents = (id)[image CGImage];
[superLayer addSublayer: sublayer];
The perspective is applied as expected. However, if I were to try and nest layers further
CALayer *sublayer = [CALayer layer];
[superLayer addSublayer: sublayer];
CALayer *nestedlayer = [CALayer layer];
nestedlayer.frame = layerFrame;
nestedlayer.contents = (id)[image CGImage];
[sublayer addSublayer: nestedlayer];
The nested layer is flat when rotated.
It's as if the superLayer only applies the transform to layers that are directly below it in the layer hierarchy. Is this the case? Or am I doing something wrong?