5

Intento implementar la animación: cuando ingresa a la Galería de iPhone, presione la imagen, verá la imagen en pantalla completa. A continuación puede ver la barra de herramientas con el botón de papelera. Cuando presiona este botón, la imagen se borrará con la animación. Intento implementar esto, pero no sé cómo implementar la transformación de imagen, uso de apple. Esta es la mejor, lo que podía hacer:Animación, como cuando elimina desde la Galería de fotos de iPhone

[UIView transitionWithView:self.view duration:0.1 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ 
     [self.view addSubview:scrollImageView]; 
    } completion:^(BOOL finished) { 
     [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ 
      CGRect frame = scrollImageView.frame; 
      frame.size = CGSizeMake(frame.size.width * 0.75, frame.size.height * 0.75); 
      frame.origin = CGPointMake((size.width - frame.size.width)/2, (size.height - frame.size.height)/2); 
      scrollImageView.frame = frame; 
     } completion:^(BOOL finished) { 
      [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ 
       CGRect frame = scrollImageView.frame; 
       frame.size = CGSizeMake(frame.size.width * 0.05, frame.size.height * 0.05); 
       frame.origin = CGPointMake(size.width, size.height); 
       scrollImageView.frame = frame; 
       CGAffineTransform transform = scrollImageView.transform; 
       CGAffineTransform rotatedTransform = CGAffineTransformRotate(transform, 45 * 3.14/180); 
       scrollImageView.transform = rotatedTransform; 
      } completion:^(BOOL finished) { 
       [scrollImageView removeFromSuperview]; 
      }]; 
     }]; 
    }]; 

gracias de antemano.

actualización Según entiendo, no puedo hacer esta animación con Core-animación, pero puede que alguien me puede aconsejar la animación más simular a iPhone Galería de animación, pero sin usar OpenGL?

Respuesta

3

En este punto, la animación exacta de la que está hablando no se puede hacer utilizando Core Animation o UIKit. Tendría que usar OpenGL y aplicar la imagen como una textura y hacer su animación allí.

+0

¿Puede aconsejarme la animación más simular a la animación de la galería de iPhone, pero sin usar OpenGL? –

+0

Anteriormente hice una [publicación de blog] (http://ronnqvist.tumblr.com/post/23234805389/unobtrusive-hints-of-joy) tratando de replicar la animación "Abrir en segundo plano" de Safari. Es bastante similar, pero al mismo tiempo muy diferente. Probablemente puedas aprender algo de él y adaptar las partes que necesitas para tu animación. –

6

Puede utilizar siguiente ejemplo de esta animación:

UIView *senderView = (UIView*)sender; 

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"]; 
      anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
      anim.duration = 0.125; 
      anim.repeatCount = 1; 
      anim.autoreverses = YES; 
      anim.removedOnCompletion = YES; 
      anim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]; 
      //[senderView.layer addAnimation:anim forKey:nil]; 


UIBezierPath *movePath = [UIBezierPath bezierPath]; 
      [movePath moveToPoint:icon.center]; 
      [movePath addQuadCurveToPoint:senderView.center 
          controlPoint:CGPointMake(senderView.center.x, icon.center.y)]; 

      CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 
      moveAnim.path = movePath.CGPath; 
      moveAnim.removedOnCompletion = YES; 

      CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"]; 
      scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; 
      scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]; 
      scaleAnim.removedOnCompletion = YES; 

      CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"]; 
      opacityAnim.fromValue = [NSNumber numberWithFloat:1.0]; 
      opacityAnim.toValue = [NSNumber numberWithFloat:0.1]; 
      opacityAnim.removedOnCompletion = YES; 

      CAAnimationGroup *animGroup = [CAAnimationGroup animation]; 
      animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim, opacityAnim, nil]; 
      animGroup.duration = 0.5; 
      [icon.layer addAnimation:animGroup forKey:nil]; 

he modificado el código, usted tiene que realizar tras los cambios en el mismo, establecer la vista remitente como self.view, y cambiar el punto final de animación (que es actualmente senderView.center) según su requisito

+0

Por favor, ¿puedes cambiar tu ejemplo utilizando mi scrollImageView y self.view? Como traté de usar scrollImageView en lugar de ícono, y la animación es horrible, creo que no entiendo nada. –

+0

@Paul Galavic - He hecho este tipo de animación? Tengo curiosidad por saberlo. También quiero implementarlo. – TheFlash

0

Creo que está hablando de la animación de transición "suck".

Es posible activarlo, pero se trata de una transición privada, y Apple puede rechazar su aplicación si la usa.

Este código debe hacerlo, utilizando un código de transición de 103:

[UIView beginAnimations: contexto nil: NULL]; [UIView setAnimationDuration: 1.0]; [UIView setAnimationTransition: transtionIndex forView: caché containerView: NO]; [containerView addSubview: newView]; [oldView removeFromSuperview]; [UIView commitAnimations];

O buscar en la red para una transición Core imagen llamada "suckEffect"

4

Sé que es un poco tarde. Pero, debe verificar la solución de Ciechan llamada BCGenieEffect. Se puede encontrar here. Es pura animación básica y muy fácil de entender. Creo que eso es lo que estás buscando.

Buena suerte

Cuestiones relacionadas