【问题标题】:Apply 3D rotation to iPhone view将 3D 旋转应用到 iPhone 视图
【发布时间】:2011-02-18 03:11:58
【问题描述】:

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

非常感谢您提供代码示例。

【问题讨论】:

标签: iphone uiview 3d rotation


【解决方案1】:

对于 2D 旋转使用:

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

有关 3D 转换,请参阅 this thread

CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0);

【讨论】:

    【解决方案2】:
    // 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];
    

    【讨论】:

      【解决方案3】:

      Swft 3 示例

      let rotationTransform = CATransform3DRotate(myView.layer.transform, CGFloat.pi, 1, 0, 0)
      
      UIView.animate(withDuration: 0.5) {
          self.myView.layer.transform = rotationTransform
      }
      

      【讨论】:

        猜你喜欢
        • 2017-11-20
        • 2012-06-05
        • 1970-01-01
        • 2023-03-31
        • 2011-05-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多