2010-05-11 7 views
5

Me gustaría aplicar una rotación 3D en una vista (en particular a un UILabel) en iPhone. ¿Cuál es la forma más sencilla de hacer esto?Aplicar rotación 3D a la vista de iPhone

Un ejemplo de código será muy apreciado.

+0

Esta pregunta es muy similar a la suya: http : //stackoverflow.com/questions/347721/ uiview-perspective-transform –

+0

Gracias Brad. ¿Crees que debería eliminar este? – hpique

Respuesta

11

Para la rotación 2D uso:

//rotate label in 45 degrees 
label.transform = CGAffineTransformMakeRotation(M_PI/4); 

Para las transformaciones 3D ver this thread:

CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0); 
8
// flipping view along axis 
// this will rotate view in 3D along any axis 

[UIView beginAnimations:nil context:nil]; 
CATransform3D _3Dt = CATransform3DRotate(self.layer.transform, 3.14, 1.0, 0.0,0.0); 
[UIView setAnimationRepeatCount:100]; 
[UIView setAnimationDuration:0.08]; 
self.layer.transform=_3Dt; 
[UIView commitAnimations]; 
0

SWFT 3 ejemplo

let rotationTransform = CATransform3DRotate(myView.layer.transform, CGFloat.pi, 1, 0, 0) 

UIView.animate(withDuration: 0.5) { 
    self.myView.layer.transform = rotationTransform 
} 
Cuestiones relacionadas