Skip to content

Instantly share code, notes, and snippets.

@tongoclinh
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save tongoclinh/7c1378c258779c5f6179 to your computer and use it in GitHub Desktop.

Select an option

Save tongoclinh/7c1378c258779c5f6179 to your computer and use it in GitHub Desktop.
Animate changing corner radius of CALayer
CABasicAnimation *cornerAnim = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
cornerAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
cornerAnim.fromValue = [NSNumber numberWithFloat:40.0f];
cornerAnim.toValue = [NSNumber numberWithFloat:5.0f];
cornerAnim.duration = 1.0;
[self.view.layer addAnimation:cornerAnim forKey:@"cornerRadius"];
self.view.layer = cornerAnim.toValue;
//self is UIViewController sub-class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment