Skip to content

Instantly share code, notes, and snippets.

@mundstein
Last active December 15, 2015 03:49
Show Gist options
  • Save mundstein/5197489 to your computer and use it in GitHub Desktop.
Save mundstein/5197489 to your computer and use it in GitHub Desktop.
View Quiviring for iOS, like in Springboard. Ideal for collection views before deleting.
// INSERT CELL ANIMATION SNIPPET HERE
- (void)startQuivering
{
CABasicAnimation *quiverAnim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
float startAngle = (-2) * M_PI/180.0;
float stopAngle = -startAngle;
quiverAnim.fromValue = [NSNumber numberWithFloat:startAngle];
quiverAnim.toValue = [NSNumber numberWithFloat:3 * stopAngle];
quiverAnim.autoreverses = YES;
quiverAnim.duration = 0.2;
quiverAnim.repeatCount = HUGE_VALF;
float timeOffset = (float)(arc4random() % 100)/100 - 0.50;
quiverAnim.timeOffset = timeOffset;
CALayer *layer = self.layer;
[layer addAnimation:quiverAnim forKey:@"quivering"];
}
- (void)stopQuivering
{
CALayer *layer = self.layer;
[layer removeAnimationForKey:@"quivering"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment