I'm playing with CATransform3DMakeRotation in a UIView, and I'm trying to do a 45º, transform like it's laying backwards:
This is the "code" I have, but clearly doesn't do it.
CATransform3D _tr = CATransform3DMakeRotation(3.14/4, 1, 0, 0);
view.layer.transform = _tr;
please help me understand the params. Thanks.
Basically, your code is correct, but to get the perspective effect, you need to set the sublayerTransform
of the superview's layer to something like this:
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 1.0 / -850;
myView.layer.sublayerTransform = perspectiveTransform;
You can experiment with different values for different amounts of distortion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With