Логика CATransform3DRotate

Я пытаюсь преобразовать мои взгляды, как на картинке: (сверху и сбоку)

введите описание изображения здесь

Я добавил каждый вид к представлению ранее (view1 добавляет view2, который добавляет view3).

У меня есть проблема, чтобы найти правильный способ вернуть view3 такой же угол назад, как view1.

Вот что я попробовал:

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 градусов. Итак, мой вопрос: как я могу повернуть от 2 до 3 с углом 45 градусов?

0 ответов

Другие вопросы по тегам