Reputation: 18096
I have CAlayers in different z-depth and i want to transform them in z depth to see all layers i tried using this method:
CATransform3D transform = CATransform3DMakeTranslation(0, 0,-50 );
rootLayer.sublayerTransform = transform;
but no change and i tried using this method
CATransform3D transform = CATransform3DRotate(trackball->baseTransform, 30, 30 , 0 , 0 );
rootLayer.sublayerTransform = transform;
for (CALayer* layer in rootLayer.sublayers)
{
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"zPosition"];
theAnimation.fromValue=[NSNumber numberWithFloat:-40]; // [NSNumber numberWithFloat:frandom(800, 400)];
theAnimation.toValue=[NSNumber numberWithFloat:200]; // [NSNumber numberWithFloat:frandom(-300, -100)];
theAnimation.duration=8;
theAnimation.repeatCount = 1e100;
[layer addAnimation:theAnimation forKey:@"zPosition"];
}
It moved in y direction
Note :Ipad orientation is landscape.
Upvotes: 2
Views: 1514
Reputation: 3389
I'm afraid the code you supplied doesn't discover the problem
Suppose we have the following structure
-> rootLayer
-> sublayer1
-> sublayer2
-> sublayer3
...
-> sublayerN
Then to get visible the sublayer2
you will need to change zPosition
to the sublayer1
but not to the rootLayer
Upvotes: 1