Sto provando a creare un'animazione che assomiglierebbe a 2 porte francesi (o 2 portelli) che si aprono verso l'utente.Come animare UIImageViews come le porte del boccaporto che si aprono
Ho provato a utilizzare la transizione incorporata di UIViewAnimationOptionTransitionFlipFromRight, ma l'origine della transizione sembra essere il centro di UIImageView anziché il bordo sinistro. Fondamentalmente ho 2 UIImageViews che ogni riempimento ha lo schermo. Mi piacerebbe che l'animazione assomigli a UIImageViews che si alza dal centro dello schermo fino ai bordi.
[UIView transitionWithView:leftView
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^ { leftView.alpha = 0; }
completion:^(BOOL finished) {
[leftView removeFromSuperview];
}];
Qualcuno ha mai fatto qualcosa del genere? Qualsiasi aiuto sarebbe fantastico!
UPDATE: codice di lavoro grazie 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: è possibile scambiare il segno meno sulle rotazioni sinistra e porta a destra per fare le porte si aprono verso l'interno. –