将3D旋转应用于iPhone视图

hpi*_*que 7 iphone 3d rotation uiview

我想在iPhone中的视图(特别是UILabel)上应用3D旋转.最简单的方法是什么?

一个代码示例将非常感激.

sas*_*eve 12

对于2D旋转使用:

//rotate label in 45 degrees
label.transform = CGAffineTransformMakeRotation( M_PI/4 );
Run Code Online (Sandbox Code Playgroud)

对于3D转换,请参阅此主题:

CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0);
Run Code Online (Sandbox Code Playgroud)


小智 9

// 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];
Run Code Online (Sandbox Code Playgroud)