首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CATransform3D动画集X轴

CATransform3D动画集X轴
EN

Stack Overflow用户
提问于 2012-12-15 06:14:58
回答 1查看 837关注 0票数 0

我有一个CATransform3D动画,旨在取代目前在我的应用程序中使用的推送动画。当前,它会旋转,就像X轴位于层/视图的中心一样。但是,我希望X轴位于屏幕的边缘,这样它就可以翻转到屏幕之外。我当前的代码是:-

代码语言:javascript
复制
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
    rotationAndPerspectiveTransform.m34 = 1.0 / 500;
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 1.57, 0, 1, 0);
    self.view.layer.transform = rotationAndPerspectiveTransform;
    [UIView commitAnimations];

我是新接触Core Graphics之类的,所以我将非常感谢任何我出错的地方的指针和提示!

EN

回答 1

Stack Overflow用户

发布于 2012-12-15 06:32:54

您应该更改图层的anchorPoint。在beginAnimations:context:方法之前使用下面这段代码。

代码语言:javascript
复制
CGRect frame = self.view.layer.frame;
self.view.layer.anchorPoint = CGPointMake(1.f, 0.5f);
self.view.layer.frame = frame;

这将更改图层的anchorPoint,而不会更改图层位置。旋转动画将围绕从锚点经过的轴进行。

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

https://stackoverflow.com/questions/13887016

复制
相关文章

相似问题

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