Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save edwardean/7d570a4d2dc7ebf02ffe7a85cb01d4f3 to your computer and use it in GitHub Desktop.
Save edwardean/7d570a4d2dc7ebf02ffe7a85cb01d4f3 to your computer and use it in GitHub Desktop.
musicAnimation
- (void)musicAnimation {
CAReplicatorLayer *r = [[CAReplicatorLayer alloc] init];
r.bounds = (CGRect){0,0,60,60};
r.position = self.view.center;
[self.view.layer addSublayer:r];
CALayer *bar = [[CALayer alloc] init];
bar.bounds = CGRectMake(0, 0, 8, 40);
bar.position = CGPointMake(10, 75);
bar.cornerRadius = 2.0;
bar.backgroundColor = [[UIColor redColor] CGColor];
[r addSublayer:bar];
CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"position.y"];
move.toValue = @(bar.position.y-35.0f);
move.duration = 0.5f;
move.autoreverses = YES;
move.repeatCount = CGFLOAT_MAX;
[bar addAnimation:move forKey:nil];
r.instanceCount = 3;
r.instanceTransform = CATransform3DMakeTranslation(20, 0, 0);
r.instanceDelay = 0.33f;
r.masksToBounds = YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment