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.
What is the best way to approach this problem?
My first approach was a finite state machine in a single method, and chain UIView
animation blocks together using a selector of that method. This failed as [button setImage:nextImage forState:UIControlStateNormal]
is not animated.
My second approach was to look at CABasicAnimation
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).
My gut feeling that approaches using multiple buttons and fading between them is plain wrong, but am not sure where to go next.
How do I smoothly fade between images in a UIButton
?
How do I chain those transitions together?
What is the right way?
Edit: The images i1, i2, i3 need to go in sequence i1 -> i2 -> i3 -> i2 -> i1 -> i2 -> i3 etc