Perdón por una gran pregunta, la pregunta real es negrita en la parte inferior, ahora algunas explicaciones.Desplazamiento animado de UIScrollView con CoreAnimation
Uso CoreAnimation en mi proyecto para animar algunos objetos que se mueven así.
CABasicAnimation *moveAnimation;
moveAnimation=[CABasicAnimation animationWithKeyPath:@"position"];
moveAnimation.duration = 2.0;
moveAnimation.repeatCount=1;
moveAnimation.autoreverses=NO;
moveAnimation.delegate = self;
moveAnimation.fromValue = [NSValue valueWithCGPoint:[crawler.layer position]];
moveAnimation.fillMode = kCAFillModeForwards;
moveAnimation.removedOnCompletion = NO;
CGPoint p;
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(100, 100)];
[crawler.layer addAnimation:moveAnimation forKey:@"moveAnimation"];
Y ahora tengo que animar el desplazamiento de algunos UIScrollView. No puedo usar el método setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
, porque no puede personalizar la duración de la animación.
que puede hacer que sea como esto
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
scrollView.contentOffset = CGPointMake(scrollView.contentOffset.x + 200, scrollView.contentOffset.y);
[UIView commitAnimations];
pero no es CoreAnimation, y el uso de 2 tipos diferentes de técnicas de animación en una aplicación no es una buena práctica, creo.
¿Hay alguna manera de utilizar una animación de base para animar el desplazamiento del contenido de UIScrollView a un punto personalizado con duración de animación personalizada? P.S. Lo siento por el mal inglés.
Muchas gracias. Esto es lo que necesito ahora. – Padavan