Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Core Animations 3D transform of UIView

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?

enter image description here

like image 839
dormitkon Avatar asked Mar 12 '13 23:03

dormitkon


1 Answers

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
}];
like image 69
bvogelzang Avatar answered Sep 21 '22 18:09

bvogelzang