我有不同 z 深度的 CAlayers,我想在 z 深度中转换它们以查看我尝试使用此方法的所有层:
CATransform3D transform = CATransform3DMakeTranslation(0, 0,-50 );
rootLayer.sublayerTransform = transform;
但没有改变,我尝试使用这种方法
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"];
}
它向y方向移动
注意:Ipad 方向是横向的。