The general idea is as follows:
Using the For loop to create n view, and add them to the variable array, using Nstimer, to achieve the effect of cyclic discoloration (ChangeColor:), the idea of color change: The background color of the I-View and i + 1 view background color Exchange, a round can be changed, ( Nstimer will automatically implement loops)
This is in the attempt to write the controller, so the view is added to Self.view, Self.view.subviews (is an array (inside the individual view))
-(void) Viewdidload {
[Super Viewdidload];
for (int i = 0; i < 6; i++) {
UIView * view = [[UIView alloc] Initwithframe:cgrectmake (i *, I *, self.view.frame.size.width-i *, self.view.fr Ame.size.height-i * 80)];//CREATE view
View.backgroundcolor = [Uicolor colorwithred:arc4random ()% 256/255.0 green:arc4random ()% 256/255.0 blue:arc4random ( )% 256/255.0 alpha:1];//background color random assignment
[Self.view addsubview:view];//add it to (array)
[View release];
}
Nstimer * timer = [Nstimer scheduledtimerwithtimeinterval:.8 target:self selector: @selector (changecolor:) UserInfo: Self.view.subviews repeats:yes];//has been circulating (self.view.subviews to (ChangeColor:))
[Timer fire];
-(void) ChangeColor: (Nstimer *) sender
{
Nsmutablearray * ary = [Nsmutablearray arrayWithArray:sender.userInfo];
UIView * v = [[UIView alloc] init];
for (int i = 0; i < ary.count-1; i++) {//swap the background color of the I view with the background color of the i + 1 view
UIView * V1 = [ary objectatindex:i];
UIView * v2 = [ary objectatindex:i + 1];
V.backgroundcolor = V1.backgroundcolor;
V1.backgroundcolor = V2.backgroundcolor;
V2.backgroundcolor = V.backgroundcolor;
}
}
IOS Neon Effect