C'è qualche modo di duplicazione dell'animazione del pulsante siri glow? Sembra assolutamente stupendo, ma al momento non ho idea di come iniziare ... ci sono png preformattati online che vengono ruotati? o è fatto con CoreAnimation?Ricrea Siri Button Glow Animation
risposta
Credo che l'animazione Siri sia realizzata con CAEmitterLayer e CAEmitterCell e quindi animata con animazione core, ma potrei sbagliarmi completamente. Ecco un po 'di codice che imita l'effetto:
// 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"];
classi CAEmitterCell e CAEmitterLayer hanno molte proprietà in modo da controllare la documentazione di più.
Suggerisco di farlo con PNG che vengono visualizzati uno ad uno in modo da ottenere un'animazione fluida. È molto più semplice della programmazione di un'animazione codificata. Il pulsante è già stato ricreato da Arron Hunt: Siri Button Photoshop File
Btw. Un'animazione sprite è davvero facile da implementare:
- (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];
}
Fonte: http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/
Hai un punto ... Quindi implementare abbastanza PNG per un'animazione di rotazione sarebbe un modo. Ho sempre pensato che simili cose dovessero essere fatte con CoreAnimation perché è più semplice da modificare in quel momento. Il link è fantastico! Ne darò un'occhiata! – konturgestaltung
Dai un'occhiata alla mia risposta modificata per un codice di esempio che esegue un'animazione sprite. Buona fortuna – Sbhklr
@Lightforce, Qualcuno ha un set di immagini PNG per questo file PSD, non ho alcuna conoscenza di Photoshop per estrarre le immagini. Può essere caricato da qualche parte dove è facile per chiunque utilizzarlo. Grazie . – user1227928
UIImageView ha una proprietà chiamata animationImages che è possibile utilizzare per specificare un elenco di immagini che si giocherà in sequenza, come una GIF animata . Questo è probabilmente il modo più semplice per farlo se vuoi controllare precisamente l'effetto.
Qualcosa di simile potrebbe essere fatto anche con CoreAnimation usando una singola immagine e animando la sua view.transform property usando CGAffineTransformMakeRotation (angle).
Questo è stato anche il mio primo pensiero ... creare un'immagine luminosa con una sfumatura e un alfa di 0 a forma di una e di un cerchio e quindi ruotarla ... ma non sono sicuro che ciò produrrebbe quell'effetto luminoso. .. perché sarebbe ancora un po 'statico? – konturgestaltung
Si potrebbe anche voler cambiare l'alfa nel tempo, in modo da sfumare l'alfa dentro e fuori mentre ruota per far sembrare che pulsi un po '. –
bello ..... che dovrebbe farlo ..... ci provo !! – konturgestaltung
- 1. UIButton AppStore buy button animation
- 2. WPF/Windows 7: Disabilita la barra di avanzamento predefinita Glow Animation
- 3. Outer Glow come shader HLSL
- 4. Ricrea Tufte Moiré vibrazioni
- 5. Ricrea rimbalzo facilitando con molla allentamento
- 6. onSuggestionClick ricrea la mia attività
- 7. Android ActionBar Ricrea Menu Opzioni
- 8. Come rendere Outer Glow Effect usando HLSL?
- 9. addSubview animation
- 10. Matplotlib Animation
- 11. Come integrare SIRI nell'app per iPhone?
- 12. Dove è iOS 6 Siri API
- 13. Button ActionListener
- 14. Gerrit che ricrea i change-id
- 15. cos'è più veloce: ricrea o clear()?
- 16. Ricrea le versioni utilizzando Carrierwave con Ruby
- 17. iPhone view move animation
- 18. CSS3 Spin Animation
- 19. End animation event android
- 20. Uiview Swipe Animation Glitches
- 21. Android ViewFlipper Animation
- 22. android recyclerview notifyItemInserted animation
- 23. animation override con: hover
- 24. Three.js - avatar animation
- 25. Abort Rubys Shoes animation
- 26. Android Animation lasciando artefatti
- 27. Genie animation Javascript?
- 28. Android Simple TextView Animation
- 29. Android Activity Transition Animation
- 30. Stop Motion Animation CSS
self.fireEmitter manca il contesto qui – Pascalius
Ho dimenticato di modificare quelle linee durante la copia del codice. Avrebbe dovuto essere self.emitterLayer. L'ho risolto – jlajlar
Hai dimenticato di dire che "ball.png" dovrebbe essere intorno a 5x5 pixel ... – Idan