Skip to content

Instantly share code, notes, and snippets.

@eytanschulman
Created June 23, 2014 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eytanschulman/32f6eb6f6223728fe698 to your computer and use it in GitHub Desktop.
Save eytanschulman/32f6eb6f6223728fe698 to your computer and use it in GitHub Desktop.
Best. Method. Ever.
-(void)changeButtonBackgroundWithAnimation:(UIButton *)button andBackground:(UIImage *)background withDuration:(CFTimeInterval)aduration {
[button setImage:background forState:UIControlStateNormal];
CATransition *transition = [CATransition animation];
transition.duration = aduration;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[button.layer addAnimation:transition forKey:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment