Estoy tratando de crear una animación que se vea como 2 puertas francesas (o 2 puertas de escotilla) que se abren hacia el usuario.Cómo animar UIImageViews como apertura de puertas de escotilla
Intenté utilizar la transición UIViewAnimationOptionTransitionFlipFromRight incorporada, pero el origen de la transición parece ser el centro del UIImageView en lugar del borde izquierdo. Básicamente tengo 2 UIImageViews que cada relleno tiene la pantalla. Me gustaría que la animación parezca que las UIImageViews se están levantando desde el centro de la pantalla hasta los bordes.
[UIView transitionWithView:leftView
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^ { leftView.alpha = 0; }
completion:^(BOOL finished) {
[leftView removeFromSuperview];
}];
¿Alguien ha hecho algo así antes? ¡Cualquier ayuda sería increíble!
ACTUALIZACIÓN: código de trabajo gracias a Nick Lockwood
leftView.layer.anchorPoint = CGPointMake(0, 0.5); // hinge around the left edge
leftView.frame = CGRectMake(0, 0, 160, 460); //reset view position
rightView.layer.anchorPoint = CGPointMake(1.0, 0.5); //hinge around the right edge
rightView.frame = CGRectMake(160, 0, 160, 460); //reset view position
[UIView animateWithDuration:0.75 animations:^{
CATransform3D leftTransform = CATransform3DIdentity;
leftTransform.m34 = -1.0f/500; //dark magic to set the 3D perspective
leftTransform = CATransform3DRotate(leftTransform, -M_PI_2, 0, 1, 0);
leftView.layer.transform = leftTransform;
CATransform3D rightTransform = CATransform3DIdentity;
rightTransform.m34 = -1.0f/500; //dark magic to set the 3D perspective
rightTransform = CATransform3DRotate(rightTransform, M_PI_2, 0, 1, 0);
rightView.layer.transform = rightTransform;
}];
Nota: puede cambiar el signo menos en las rotaciones de izquierda y la puerta derecha para hacer las puertas se abren hacia adentro –