First a small square with a shadow.

When the button is pressed, the square and shadow grow together.

The main code is given below:
[CATransaction begin]; [CATransaction setAnimationDuration:5.0]; CAMediaTimingFunction *timing = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; [CATransaction setAnimationTimingFunction:timing]; layer.frame = CGRectMake(0,0,100,100); [CATransaction commit]; CABasicAnimation *shadowAnimation = [CABasicAnimation animationWithKeyPath:@"shadowPath"]; shadowAnimation.duration = 5.0; shadowAnimation.fromValue = (id)[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 50, 50)].CGPath; shadowAnimation.toValue = (id)[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)].CGPath; [layer addAnimation:shadowAnimation forKey:@"shadow"];
You can download this project from GitHub and just run it.
https://github.com/weed/p120812_CALayerShadowTest
This question was very difficult for me! :)
source share