¿Cómo se rota UIView
, UIImageView
o CALayer
animada 360 degress sin utilizar OpenGL ES?¿Cómo rotar UIView, UIImageView o CALayer animated 360˚?
5
A
Respuesta
3
¿Se supone que se refiere a la animación girando un UIImage
alrededor de un 360 ° completo? En mi experiencia, la manera de lograr una rotación completa el círculo es encadenar múltiples animaciones juntos:
- (IBAction)rotate:(id)sender
{
[UIView beginAnimations:@"step1" context:NULL]; {
[UIView setAnimationDuration:1.0];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
[imageView.transform = CGAffineTransformMakeRotation(120 * M_PI/180);
} [UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
if ([animationID isEqualToString:@"step1"]) {
[UIView beginAnimations:@"step2" context:NULL]; {
[UIView setAnimationDuration:1.0];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
imageView.transform = CGAffineTransformMakeRotation(240 * M_PI/180);
} [UIView commitAnimations];
}
else if ([animationID isEqualToString:@"step2"]) {
[UIView beginAnimations:@"step3" context:NULL]; {
[UIView setAnimationDuration:1.0];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
imageView.transform = CGAffineTransformMakeRotation(0);
} [UIView commitAnimations];
}
}
que he dejado la curva easeIn/easeOut
(en lugar de lineal) en su lugar, para que pueda ver las animaciones individuales.
28
#import <QuartzCore/QuartzCore.h>
CABasicAnimation *fullRotation;
fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = @(0.0);
fullRotation.toValue = @((360.0 * M_PI)/180.0);
fullRotation.duration = 3.5f;
fullRotation.repeatCount = MAXFLOAT;
[view.layer addAnimation:fullRotation forKey:@"rotation-animation"];
Si desea cambiar el punto de anclaje que gira en torno a continuación, puede hacer
CGRect frame = view.layer.frame;
self.anchorPoint = CGPointMake(0.5, 0.5); // rotates around center
self.frame = frame;
Cuestiones relacionadas
- 1. Esquinas redondeadas UIView o UIImageView
- 2. Animación de UIView enmascarado, CALayer
- 3. UIImageView rellenar UIView
- 4. CALayer performance vs. UIImageView performance
- 5. cómo rotar CALayer en un punto
- 6. ¿Cómo rotar un UIImageView con CATransform3DRotate hace un efecto como la apertura de la puerta?
- 7. Aplicar múltiples transformaciones a un UIView/CALayer
- 8. ¿Es posible copiar CALayer de UIView?
- 9. UIImageView vs UIView w/Image - efficiency
- 10. ¿Cómo agrego un resplandor exterior a un UIImage o UIImageView o UIView
- 11. CALayer Sombras desaparecen durante una animación UIView
- 12. Cómo hacer un antialiasing en una UIView girada (NO UIImageView)
- 13. ¿Cómo puedo agregar programáticamente un UIImage a un UIImageView y agregar ese UIImageView a otro UIView?
- 14. UIImageView "aplastado" después de CGAffineTransformMakeRotation
- 15. bordes de suavizado de líneas de UIView después de la transformación utilizando CALayer de transformada
- 16. cómo oscurecer un UIImageView
- 17. UIImageView muestra MUCHO más rápido que CG o CALayer. Alguien sabe por qué?
- 18. Cómo rotar el texto Swing?
- 19. ¿Cuál es la relación entre UIView y CALayer
- 20. ¿Cómo ocultar/mostrar UIimageview?
- 21. Animando a CALayer de UIView para redondear esquinas
- 22. CATransform3DRotate rotate para 360 grados
- 23. Mostrar una imagen o UIImage con un plano CALayer
- 24. Envoltura/deformación de un CALayer/UIView (u OpenGL) en 3D (iPhone)
- 25. Sombra que no aparece para UIView con CALayer
- 26. poner subvistas de un UIView en frente de su CALayer?
- 27. La aplicación de la física Box2D a UIView vs CALayer
- 28. ¿Cuáles son las diferencias entre un UIView y un CALayer?
- 29. ¿Puedo usar CGAffineTransformMakeRotation para rotar una vista de más de 360 grados?
- 30. Diferente transición en presentModalViewController: animated:
¿Se da cuenta de que la rotación de 360˚ le dará exactamente la misma imagen, ¿verdad? – SteamTrout
Me parece triste que comencé a tratar de pensar en una solución antes de darme cuenta de eso. – jtbandes
@Steam Trout: solo si quiere que sea instantáneo. – JeremyP