CATransform3DRotate的逻辑

时间:2014-05-12 16:11:10

标签: objective-c catransform3d catransformlayer

我尝试将我的观点转换为类似图片:(顶部和侧面视图)

enter image description here

我之前将每个视图添加到视图中(view1添加了添加view3的view2)。

我很难找到像view1一样给view3提供相同角度的正确方法。

这就是我的尝试:

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
    rotationAndPerspectiveTransform.m34 = (1.0/ 500);
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 45.0 / 180.0 * M_PI , 1, 0, 0);

    [UIView animateWithDuration:0.6 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

        self.view1.layer.transform = rotationAndPerspectiveTransform;

    } completion:nil];


    rotationAndPerspectiveTransform = CATransform3DIdentity;
    rotationAndPerspectiveTransform.m34 = (1.0/500);
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, -45.0 / 180.0 * M_PI , 1, 0, 0);

    [UIView animateWithDuration:0.6 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

        self.view2.layer.transform = rotationAndPerspectiveTransform;

    } completion:nil];


    rotationAndPerspectiveTransform = CATransform3DIdentity;
    rotationAndPerspectiveTransform.m34 = (1.0/500);
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 4.5 / 180.0 * M_PI , 1, 0, 0);


    [UIView animateWithDuration:0.6 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

        self.view3.layer.transform = rotationAndPerspectiveTransform;

    } completion:nil];

使用此代码,我的View3转动不到45度。 所以我的问题是:如何以45度的角度从by2转到view3?

0 个答案:

没有答案
相关问题