Im juste un débutant donc je ne sais pas si c'est l'endroit correct à demander.Couleur Cycle Xcode UIView fond
J'ai trouvé ce code sur votre site pour faire une application Xcode iphone où les cycles de couleurs d'arrière-plan - UIView backgroundColor color cycle
et il fonctionne très bien! Comment est-ce que je pourrais l'ajuster de sorte qu'il ne fasse qu'un cycle et se termine sur la dernière couleur du tableau?
Nous vous remercions de votre aide.
// ViewController.m
// colorCycle
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self doBackgroundColorAnimation];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) doBackgroundColorAnimation {
static NSInteger i = 0;
NSArray *colors = [NSArray arrayWithObjects:[UIColor greenColor], [UIColor yellowColor], [UIColor orangeColor], [UIColor redColor], nil];
if(i >= [colors count]) {
i = 0;
}
[UIView animateWithDuration:2.0f animations:^{
self.view.backgroundColor = [colors objectAtIndex:i];
} completion:^(BOOL finished) {
++i;
[self doBackgroundColorAnimation];
}];
}