15

我正在尝试使用 CA 制作简单的部分翻转动画,但我遇到了透视问题。我试过:

    [UIView animateWithDuration:1.0 animations:^{
    self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
    self.someView.layer.transform = CATransform3DMakeRotation(M_PI*0.6,1.0,0.0,0.0);
} completion:^(BOOL finished){
    // code to be executed when flip is completed
}];

如何获得这个美好的视角?

在此处输入图像描述

4

2 回答 2

32

这样的事情会做:

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -1000.0;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI * 0.6, 1.0f, 0.0f, 0.0f);
[UIView animateWithDuration:1.0 animations:^{
    self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
    self.someView.layer.transform = rotationAndPerspectiveTransform;
} completion:^(BOOL finished){
    // code to be executed when flip is completed
}];
于 2013-03-12T23:46:01.483 回答
1

如何将透视变换应用于 UIView?

请参阅有问题的答案。

基本上你修改矩阵的 m34 来控制有多少对象收缩到背景中。

如果您更好奇,请查看: http: //www.songho.ca/opengl/gl_projectionmatrix.html

于 2013-03-12T23:46:31.803 回答