I am trying to make a simple Simon game (an increasing sequence of colors flashes, and the user should try to repeat this sequence). The way I do this is 4 UIViews with 8 images. So, UIView for red, blue, green and yellow. And I have gifs dark green, light green, dark red, light red, etc.
So, in my code, I use UIView transitionWithView: UIView imageView.image is used by default with a dark color image, and this unit goes to a light color image, and when finished returns to a dark color image (so that it looks “illuminated”).
- (void) animateColor:(NSString *)color
{
...
...
[UIView transitionWithView:imageView
duration:.5
options: UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAutoreverse
animations:^{
imageView.image = [UIImage imageNamed:lightImage];
}
completion:^(BOOL finished){
if (finished){
imageView.image = [UIImage imageNamed:darkImage];
}
}];
}
This works great when I call it a single color method of this code.
, NSArray , . , "", "", , WithView , , . .
NSTimer , - .
.