#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
for (NSInteger i = 7; i >= 1; i--) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50 * i, 50 * i)];
view.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255. green:arc4random() % 256 / 255. blue:arc4random() % 256 / 255. alpha:1.0];
view.center = self.view.center;
view.tag = 100 + i;
[self.view addSubview:view];
[view release];
}
[NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(changeColor) userInfo:nil repeats:YES];
}
- (void)changeColor {
for (NSInteger i = 1; i <= 6; i++) {
UIView *view1 = (UIView *)[self.view viewWithTag:100 + i];
UIView *view2 = (UIView *)[self.view viewWithTag:100 + i + 1];
view1.backgroundColor = view2.backgroundColor;
}
UIColor *color = [UIColor colorWithRed:arc4random() % 256 / 255. green:arc4random() % 256 / 255. blue:arc4random() % 256 / 255. alpha:1.0];
UIView *view = (UIView *)[self.view viewWithTag:107];
view.backgroundColor = color;
}