¿Hay alguna manera de duplicar la animación del botón sir glow? Se ve absolutamente precioso, pero no tengo ni idea en este momento de cómo empezar ... ¿hay png preformateados en línea que se roten? o se hace con CoreAnimation?Recreate Siri Button Glow Animation
Respuesta
Creo que la animación de Siri se hace con CAEmitterLayer y CAEmitterCell y luego se anima con animación central, pero podría estar totalmente equivocado. Aquí hay un código que imita el efecto:
// create emitter layer
self.emitterLayer = [CAEmitterLayer layer];
self.emitterLayer.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
self.emitterLayer.emitterMode = kCAEmitterLayerOutline;
self.emitterLayer.emitterShape = kCAEmitterLayerLine;
self.emitterLayer.renderMode = kCAEmitterLayerAdditive;
[self.emitterLayer setEmitterSize:CGSizeMake(4, 4)];
// create the ball emitter cell
CAEmitterCell *ball = [CAEmitterCell emitterCell];
ball.color = [[UIColor colorWithRed:111.0/255.0 green:80.0/255.0 blue:241.0/255.0 alpha:0.10] CGColor];
ball.contents = (id)[[UIImage imageNamed:@"ball.png"] CGImage]; // ball.png is simply an image of white circle
[ball setName:@"ball"];
self.emitterLayer.emitterCells = [NSArray arrayWithObject:ball];
[self.view.layer addSublayer:self.emitterLayer];
float factor = 1.5; // you should play around with this value
[self.emitterLayer setValue:[NSNumber numberWithInt:(factor * 500)] forKeyPath:@"emitterCells.ball.birthRate"];
[self.emitterLayer setValue:[NSNumber numberWithFloat:factor * 0.25] forKeyPath:@"emitterCells.ball.lifetime"];
[self.emitterLayer setValue:[NSNumber numberWithFloat:(factor * 0.15)] forKeyPath:@"emitterCells.ball.lifetimeRange"];
// animation code
CAKeyframeAnimation* circularAnimation = [CAKeyframeAnimation animationWithKeyPath:@"emitterPosition"];
CGMutablePathRef path = CGPathCreateMutable();
CGRect pathRect = CGRectMake(0, 0, 200, 200); // define circle bounds with rectangle
CGPathAddEllipseInRect(path, NULL, pathRect);
circularAnimation.path = path;
CGPathRelease(path);
circularAnimation.duration = 2;
circularAnimation.repeatDuration = 0;
circularAnimation.repeatCount = 3;
circularAnimation.calculationMode = kCAAnimationPaced;
[self.emitterLayer addAnimation:circularAnimation forKey:@"circularAnimation"];
clases CAEmitterCell y CAEmitterLayer tienen muchas propiedades a fin de comprobar la documentación para más.
Le sugiero que lo haga con PNG que se muestran uno por uno, de modo que se obtiene una animación suave. Es mucho más fácil que programar una animación codificada. El botón ya ha sido recreado por Arron Hunt: Siri Button Photoshop File
Btw. Una animación de sprites es muy fácil de implementar:
- (void)viewDidLoad {
[super viewDidLoad];
NSArray * imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
[UIImage imageNamed:@"5.png"],
[UIImage imageNamed:@"6.png"],
[UIImage imageNamed:@"7.png"],
[UIImage imageNamed:@"8.png"],
[UIImage imageNamed:@"9.png"],
[UIImage imageNamed:@"10.png"],
[UIImage imageNamed:@"11.png"],
[UIImage imageNamed:@"12.png"],
nil];
UIImageView * ryuJump = [[UIImageView alloc] initWithFrame:
CGRectMake(100, 125, 150, 130)];
ryuJump.animationImages = imageArray;
ryuJump.animationDuration = 1.1;
ryuJump.contentMode = UIViewContentModeBottomLeft;
[self.view addSubview:ryuJump];
[ryuJump startAnimating];
}
Fuente: http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/
Tienes un punto ... Así que implementar suficientes PNG para una animación de rotación sería una manera. Siempre pensé que tales cosas deberían hacerse con CoreAnimation porque es más fácil de modificar en ese momento. ¡El enlace es genial! Voy a echar un vistazo a eso! – konturgestaltung
Eche un vistazo a mi respuesta editada para un código de muestra que hace una animación de sprite. Buena suerte – Sbhklr
@Lightforce, ¿Alguien puede tener un conjunto de imágenes PNG para este archivo PSD? No tengo ningún conocimiento de Photoshop para extraer las imágenes. ¿Alguien puede subirlo a alguna parte para que sea fácil de usar por todos? . – user1227928
UIImageView tiene una propiedad llamada animationImages que se pueden utilizar para especificar una lista de imágenes que se reproducirá en secuencia, como un GIF animado . Esa es probablemente la forma más fácil de hacerlo si desea controlar con precisión el efecto.
Algo similar también podría hacerse con CoreAnimation utilizando una sola imagen y animando su propiedad view.transform utilizando CGAffineTransformMakeRotation (ángulo).
Esa fue mi primera idea también ... hacer una imagen brillante con un degradado y alfa de 0 a la vez y en forma de círculo y luego rotar esa cosa ... pero no estoy seguro de si eso produciría ese efecto brillante. .. porque todavía se vería un poco estático? – konturgestaltung
También es posible que desee variar el alfa a lo largo del tiempo, por lo tanto, disminuya la entrada y la salida del alfa a medida que gira para que parezca que pulsa un poco. –
nice ..... that should do it ..... ¡Pruébalo! – konturgestaltung
- 1. WPF/Windows 7: Desactiva la barra de progreso predefinida Glow Animation
- 2. Siri lenguaje de programación
- 3. Recreate Source Data from PivotTable Cache
- 4. Donde es iOS 6 Siri API
- 5. addSubview animation
- 6. UISearchBar Animation
- 7. translate animation
- 8. Pulsing Animation
- 9. UIWindow animation
- 10. Jquery datepicker button tabindex
- 11. Button y estirable dejaron
- 12. Android Button Position Programmatically
- 13. UITableView Edit/Done Button
- 14. ExtJS Button Style Toolbar
- 15. uiBinder en Button Clickevent
- 16. Multi-State Toggle Button
- 17. WPF button textwrap style
- 18. UITableview edit/done button
- 19. Brush to Brush Animation
- 20. Android Simple TextView Animation
- 21. jQuery Tab Fade Animation
- 22. WPF Progressbar continue animation
- 23. Core Animation - Page flip
- 24. Android 3D animation
- 25. UIModalTransitionStyleFlipHorizontal animation duration?
- 26. Android: LinearLayout addView Animation
- 27. webkit css3 animation loop
- 28. Core Animation ... animaciones cíclicas?
- 29. Android Animation Flicker
- 30. Android ViewFlipper Animation
self.fireEmitter falta el contexto aquí – Pascalius
He olvidado editar esas líneas al copiar el código. Debería haber sido self.emitterLayer. Lo he arreglado – jlajlar
Olvidó mencionar que "ball.png" debería tener un tamaño de 5x5 píxeles ... – Idan