You'll probably need to go down to the Core Animation layer. The shadow property of the UIButton's layer is animatable, so you can create a repeating CABasicAnimation I change the shadow color/size and add it to the layer. The following code worked for me.
button.layer.shadowPath = [[UIBezierPath bezierPathWithRect:CGRectInset(button.bounds, -3, -3)] CGPath];
button.layer.shadowColor = [[UIColor whiteColor] CGColor];
button.layer.shadowOpacity = 1.0f;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"shadowColor"];
animation.fromValue = (id)[[UIColor darkGrayColor] CGColor];
animation.toValue = (id)[[UIColor lightGrayColor] CGColor];
animation.duration = 1.0f;
animation.autoreverses = YES;
animation.repeatCount = NSIntegerMax;
[button.layer addAnimation:animation forKey:@"shadow"];
And attach these methods appropriate to the button's control events.
-(IBAction)userDidTouchDown:(UIButton *)sender
{
[button.layer removeAnimationForKey:@"shadow"];
}
-(IBAction)userDidTouchUp:(UIButton *)sender
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"shadowColor"];
animation.fromValue = (id)[[UIColor darkGrayColor] CGColor];
animation.toValue = (id)[[UIColor lightGrayColor] CGColor];
animation.duration = 1.0f;
animation.autoreverses = YES;
animation.repeatCount = NSIntegerMax;
[button.layer addAnimation:animation forKey:@"shadow"];
}
You can play around with the shadow values (particularly the path) to get it right for you. Don't forget to attach userDidTouchUp: with both the touch up inside and touch up outside events.