首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CATransform3D不能正常工作

CATransform3D不能正常工作
EN

Stack Overflow用户
提问于 2012-09-17 19:24:13
回答 1查看 750关注 0票数 2

CATransform3D不能正常工作,我正在使用下面的代码。我的问题是,如果我改变变换,它就能正常工作。一旦我松开手指,然后进行更多的变换,图像就会转到初始图像。如何设置最后一次转换?我使用PanGesture进行转换。请给出一些想法。提前谢谢。

代码语言:javascript
复制
if ([recognizer respondsToSelector:@selector(translationInView:)]) {
    CGPoint translation = [(UIPanGestureRecognizer *)recognizer translationInView:recognizer.view.superview];
    CALayer *layer = self.layer;
    CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
    rotationAndPerspectiveTransform.m34 = 1.0 / -500;
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, translation.x * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
    layer.transform = rotationAndPerspectiveTransform;
    rotationAndPerspectiveTransform.m34 = 1.0 / -500;
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, -translation.y * M_PI / 180.0f, 1.0f, 0.0f, 0.0f);
    layer.transform = rotationAndPerspectiveTransform;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-17 21:30:34

CATransform3DIdentity意味着每次你的视图接收到触摸时,你都会重置转换。请改用CATransform3D rotationAndPerspectiveTransform = layer.transform;

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12458196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档