Z方向UIView旋转?
我正在使用以下代码来旋转 UIView 的 z 方向。它在右侧旋转。但我想旋转底部而不是右侧(因为它在右侧)。
UIView *myView = self.view;
CALayer *layer = myView.layer;
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -2000;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -500;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 45.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;
I am using following code for rotating z direction the UIView. It rotates in right side. But I want to rotate bottom side instead of right side (as it is in right side).
UIView *myView = self.view;
CALayer *layer = myView.layer;
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -2000;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -500;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 45.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否查看过 CATransform3DRotate 函数采用的参数?
最后三个元素定义视图将翻转的矢量。你的向量平行于 y 轴。尝试使用此方法来绕垂直轴旋转。
您可能需要更改锚点以使轴位于正确的“高度”。
Have you looked at the parameters the
CATransform3DRotate
function takes?The last three elements define the vector the view will flip around. Your vector is parallel to the y axis. Try this instead for the rotation around a vertical axis.
You might need to change the anchor point to get the axis on the right "height".