title: Crossfading between 3 images in a UIButton, on iOS
body: <p>I am trying to implement a clickable image that is able to repeatedly cycle through three or more images. I don't need to interact with the images once the cycle is set up. The cycling is time based, rather than event based. The images should smoothly transition from one to another.</p>
  
  <p>What is the best way to approach this problem?</p>
  
  <p>My first approach was a finite state machine in a single method, and chain <code>UIView</code> animation blocks together using a selector of that method. This failed as <code>[button setImage:nextImage forState:UIControlStateNormal]</code> is not animated.</p>
  
  <p>My second approach was to look at <code>CABasicAnimation</code> and layers. This seemed to be a more low level approach, but I couldn't see a way of chaining the transitions together (e.g. setting a next action once this action was complete).</p>
  
  <p>My gut feeling that approaches using multiple buttons and fading between them is plain wrong, but am not sure where to go next. </p>
  
  <p><strong>How do I smoothly fade between images in a <code>UIButton</code>?</strong></p>
  
  <p>How do I chain those transitions together?</p>
  
  <p>What is the right way?</p>
  
  <p><strong>Edit:</strong> 
  The images i1, i2, i3 need to go in sequence i1 -> i2 -> i3 -> i2 -> i1 -> i2 -> i3 etc</p>