Skip to content

Instantly share code, notes, and snippets.

@Pegolon
Created July 14, 2015 13:42
Show Gist options
  • Select an option

  • Save Pegolon/d2a9b31223be77deb2f4 to your computer and use it in GitHub Desktop.

Select an option

Save Pegolon/d2a9b31223be77deb2f4 to your computer and use it in GitHub Desktop.
Highlight layer with short animation
CABasicAnimation *color = [CABasicAnimation animationWithKeyPath:@"borderColor"];
color.fromValue = (id)[UIColor clearColor].CGColor;
color.toValue = (id)[UIColor redColor].CGColor;
CABasicAnimation *width = [CABasicAnimation animationWithKeyPath:@"borderWidth"];
width.fromValue = @0;
width.toValue = @1.5;
CAAnimationGroup *both = [CAAnimationGroup animation];
both.duration = 0.5;
both.animations = @[color, width];
both.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
both.autoreverses = YES;
both.repeatCount = 1;
[hitLayer addAnimation:both forKey:@"color and width"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment