Using 3D rotation to view iPhone

I would like to apply 3D rotation in the view (in particular, to UILabel) on the iPhone. What is the easiest way to do this?

Sample code is welcome.

+5
source share
3 answers

For two-dimensional rotation, use:

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

For 3D transforms see this thread :

CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0);
+11
source
// 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];
+8
source

3-

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

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

All Articles