문제

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.

도움이 되었습니까?

해결책

@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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top