Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe that Siri animation is made with CAEmitterLayer and CAEmitterCell and then animated with core animation, but I might be totally wrong. Here's some code that imitates the effect:</p> <pre><code>// 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"]; </code></pre> <p>CAEmitterCell and CAEmitterLayer classes have many properties so check out the docs for more.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload