Question

I am newbie with CATransform3D. I'm tru to use this code to make 3D transformation effect on my UIImageView.

CALayer *layer = imageView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -500;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, aSlider.value, xSlider.value, ySlider.value, zSlider.value);
layer.transform = rotationAndPerspectiveTransform;

My problem is that UIImageView after transform cuts throug views, that lies abowe them in subviews array. That's before transformation Before transformation

And that is after transformation.

enter image description here

I need just transform imageview, without overlaping another views. How can I do this?

PS. Sorry for the bad English and big images.

Was it helpful?

Solution

@Padavan, Here it looks like your Z axis of Layer are intersecting.

try this:

CGFloat zOrigin = -100; // You can change this value as required.
layer.transform = CATransform3DMakeTranslation(0, 0,zOrigin);

this will push your layer back and it will not intersect.

Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top