title: Animating UIButtons
body: <p>I have a few buttons I would like to animate.</p>
  
  <p>I have looked at and tried the animateWithDuration method but that seems to be for Views and I couldnt get my implementation to work. </p>
  
  <p>Can this method work for animating buttons too? if not how could it be done?</p>
  
  <p>EDIT 
  I have the following code </p>
  
  <pre><code>-(void) animate:(UIButton*) b withMonster: (int) monster withState: (int) state andLastState:(int) last_state {
  if (state &lt; last_state) {
      float duration = 1.0 / 10;
      __block int stateTemp = state;
      [b animateWithDuration: duration
                  animations: ^{ [UIImage imageNamed:[NSString stringWithFormat:@"m%d.a000%d.png", monster, state]]; }
                  completion: ^{ [self animate: A1 withMonster: monster withState: stateTemp++ andLastState: last_state];; }];
  
  
  }
  </code></pre>
  
  <p>and I call it like so</p>
  
  <pre><code>[self animate: A1 withMonster: monsterDecider withState: 1 andLastState: 5];
  </code></pre>
  
  <p>When this code executes the app crashes.</p>
  
  <p>Is it correct to call is with self in both calls(self being ViewController).</p>
  
  <p>Thanks</p>