I'm trying to apply a perspective transform to my UIView object with the following code:
CATransform3D t = CATransform3DIdentity;
t.m34 = -1.0/1000;
t = CATransform3DRotate(t, angle, 0.0f, 1.0f, 0.0f);
myView.layer.transform = t;
and I don't see any effect at all. I tried other transforms like a simple translation and they don't work either.
However, if I do either of the following two modifications then it will work somewhat but neither satisfies my request:
Change the last line to
myView.layer.sublayerTransform = t;
This sort of works but it only transforms the subviews on myView, not myView itself.
Add an animation code to apply the change instead of directly assign the change to the layer:
CABasicAnimation *turningAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; turningAnimation.toValue = [NSValue valueWithCATransform3D:t]; turningAnimation.delegate = self; turningAnimation.fillMode = kCAFillModeForwards; turningAnimation.removedOnCompletion = NO;
[myView.layer addAnimation:turningAnimation forKey:@"turning"];
The thing is that I don't want the animation.
Can anybody point a direction for me?
Thanks!