I originally expected that by changing the zPosition, the size would change (because it looks farther away ) But when I set the zPosition property, the size will not change, but when I use CATransform3DTranslate it will change.
Why? The following are the differences:
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -4000;
myLayer.transform = transform;< br />myLayer.zPosition = -500;
and
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -4000;
transform = CATransform3DTranslate(transform, 0, 0, -500);
myLayer.transform = transform;
The role of the latter is in line with my expectations, but I want to understand why The first one does not.
I have a layer, which I am modifying Its m34 transform property to get the perspective view.
I originally expected that by changing the zPosition, the size would change (because it looks further away) but when I set the zPosition property, the size does not change, but when I use CATransform3DTranslate It will change.
Why is this? The following are the differences:
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -4000;
myLayer.transform = transform;< br />myLayer.zPosition = -500;
and
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -4000;
transform = CATransform3DTranslate(transform, 0, 0, -500);
myLayer.transform = transform;
The role of the latter is in line with my expectations, but I want to understand why The first one does not.
zPosition only applies to the drawing order of the sibling layers, not to the perspective view: you can use it to get the Front”/”Send to Back” effect without adding/removing layers.