我有一个CATransform3D动画,旨在取代目前在我的应用程序中使用的推送动画。当前,它会旋转,就像X轴位于层/视图的中心一样。但是,我希望X轴位于屏幕的边缘,这样它就可以翻转到屏幕之外。我当前的代码是:-
[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之类的,所以我将非常感谢任何我出错的地方的指针和提示!
发布于 2012-12-15 06:32:54
您应该更改图层的anchorPoint。在beginAnimations:context:方法之前使用下面这段代码。
CGRect frame = self.view.layer.frame;
self.view.layer.anchorPoint = CGPointMake(1.f, 0.5f);
self.view.layer.frame = frame;这将更改图层的anchorPoint,而不会更改图层位置。旋转动画将围绕从锚点经过的轴进行。
https://stackoverflow.com/questions/13887016
复制相似问题