I'm trying to rotate a UIView object like shown on the image below
http://i.piccy.info/i7/f8ff7fe488c7c492e6ff6a689bc9cdeb/1-5-2127/60800682/rotation.png
I'm trying to use the CALayer's transform but I get something like this:
http://i.piccy.info/i7/bbb672b058fdfdd251cc90f1ce2b9c1f/1-5-2128/9488743/rotate2.png
If I understand correctly, you want to title the view backwards (into the screen) an should be able to achieve it something like this:
float distance = 50;
CATransform3D basicTrans = CATransform3DIdentity;
basicTrans.m34 = 1.0 / -distance;
view.layer.transform = CATransform3DRotate(basicTrans, M_PI_4, 1.0f, 0.0f, 0.0f);
To achieve this effect you need to manipulate one of the transformation values directly (m34). The lower distance
gets, the stronger the effect gets. Then you can do the rotation transformation around the x axis (to tilt), in this case PI/4 or 45 degrees. You can calculate arbitrary values pi using degrees * M_PI / 180.0
.