Rotate 3D got issue in X axis

2019-08-24 04:28发布

问题:

I have rotate3d one image.. Here is my code..

CALayer *layer = backImageView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -300;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 15.0f * M_PI / 180.0f, 1.0f, 0.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;

As before putting background image looks like

After

But when i put one more image as a background it looks like this..

X(-ve) - axis should not be displayed..

Is there any thing wrong in code or need to add extra logic or code ?

Thanks..

回答1:

I had the same problem. Its happens becouse before rotation both images lay in the same plane, but after rotation part of the image appears behind the plane and covered by another. My solution was to drag one of the images on another plane, so they do not overlap.

grayImage.layer.transform=CATransform3DMakeTranslation(0, 0, -100);

Where grayImage your second image.