Objective-c CATransform3DMakeRotation Clockwise/Counterclockwise

痴心易碎 提交于 2020-01-03 04:46:26

问题


I'm rotating an UIView along the x axis using CATransform3DMakeRotation using the below code:

  float radians = DegreesToRadians(30);
    [UIView animateWithDuration:0.15 animations:^{  
        self.moveControlView.layer.transform = CATransform3DMakeRotation(radians,1,0,0);
    }];

The rotation is applied always in the same versus (clockwise). I want to rotate the UIView in the opposite versus. In order to achieve my goal I've tried:

  • Set a negative angle (-30)
  • Set the angle to 330

But the versus of the orientation doesn't change.

I have also try to set x = -1 leaving the angle positive.

Any suggestion?


回答1:


You should apply a perspective to your transform, as it's explained in the similar question:

CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 1.0 / -500;

self.moveControlView.layer.transform = 
CATransform3DRotate(perspectiveTransform, radians, 1.0f, 0.0f, 0.0f);;


来源:https://stackoverflow.com/questions/27330252/objective-c-catransform3dmakerotation-clockwise-counterclockwise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!