views:

639

answers:

2

I would like apply a 3D rotation on a view (in particular to a UILabel) in iPhone. What's the simplest way to do this?

A code example will be much appreciated.

+4  A: 

For 2D rotation use:

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

For 3D transformations see this thread:

CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0);
sashaeve
+1  A: 

//fliping view along axis's 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:.08]; self.layer.transform=_3Dt; [UIView commitAnimations];

ankit