I'm trying to make simple partly flip animation with CA, but I had a problems with perspective. I tried with:
[UIView animateWithDuration:1.0 animations:^{
self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
self.someView.layer.transform = CATransform3DMakeRotation(M_PI*0.6,1.0,0.0,0.0);
} completion:^(BOOL finished){
// code to be executed when flip is completed
}];
How to get this nice perspective?
Something like this would do:
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -1000.0;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI * 0.6, 1.0f, 0.0f, 0.0f);
[UIView animateWithDuration:1.0 animations:^{
self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
self.someView.layer.transform = rotationAndPerspectiveTransform;
} completion:^(BOOL finished){
// code to be executed when flip is completed
}];
How do I apply a perspective transform to a UIView?
See answer in question.
Basically you modify m34 of the matrix which controls how much objects shrink into the background.
If you are more curious check out :
http://www.songho.ca/opengl/gl_projectionmatrix.html