Skip to content

Instantly share code, notes, and snippets.

View tinybot-ca's full-sized avatar

Michael Whang tinybot-ca

  • Tinybot
  • Vancouver, BC
View GitHub Profile
@qnoid
qnoid / gist:6140282
Created August 2, 2013 14:29
Animate an UIBarButtonItem that has been assigned a UIButton as its customview. The UIButton uses an image that is mirrored on the X axis hence appear as if it's rotating.
-(IBAction)tap:(id)sender
{
UIBarButtonItem *refresh = self.navigationItem.rightBarButtonItem;
CALayer *layer = ((UIButton*)refresh.customView).imageView.layer;
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotate.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
rotate.fromValue = @(0);
rotate.toValue = @(2 * M_PI);