2013-03-12 8 views
8

Próbuję zrobić prostą animację częściowo przerzucania z CA, ale miałem problem z perspektywą. Próbowałem z:Proste animacje rdzenia Transformacja 3D UIView

[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 
}]; 

Jak uzyskać tę ładną perspektywę?

enter image description here

+1

zduplikowane pytanie? - http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-viewview –

Odpowiedz

26

Coś jak to zrobi:

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 
}]; 
+0

To prawie tak, ale musi być na zewnątrz, a nie w środku. Szara linia jest naprawiona na obrazie. – dormitkon

+0

grał trochę z własnością m34, (1.0/-1000) i teraz wygląda ładnie :) thx – dormitkon