IOS 彩虹灯 程序

//

//  CaiHong.m

//  UICai

//

//  Created by Ibokan on 12-8-20.

//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.

//


#import "CaiHong.h"

#define CGRectMake_1 CGRectMake(30,30,260,400)

#define CGRectMake_2 CGRectMake(50,60,220,360)

#define CGRectMake_3 CGRectMake(70,70,180,320)

#define CGRectMake_4 CGRectMake(90,90,140,280)

#define CGRectMake_5 CGRectMake(110,110,120,240)

#define CGRectMake_6 CGRectMake(130,130,80,200)

#define CGRectMake_7 CGRectMake(150,150,40,160)

@implementation CaiHong

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


- (void)didReceiveMemoryWarning

{

    // Releases the view if it doesn't have a superview.

    [super didReceiveMemoryWarning];

    

    // Release any cached data, images, etc that aren't in use.

}


#pragma mark - View lifecycle


 


- (void) dealloc

{

  

    [super dealloc];

}

- (void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor=[UIColor blackColor];

    self.view.tag=11;

    //view1 

    UIView *view1=[[UIView alloc]initWithFrame:CGRectMake_1];

    view1.backgroundColor=[UIColor purpleColor];

    [self.view addSubview:view1]; 

    view1.tag=100;

    [view1 release];

    //view2

    UIView *view2=[[UIView alloc]initWithFrame:CGRectMake_2];

    view2.backgroundColor=[UIColor cyanColor];

    [self.view addSubview:view2];

    view2.tag=101;

    [view2 release];

    //view3

    UIView *view3=[[UIView alloc]initWithFrame:CGRectMake_3];

    view3.backgroundColor=[UIColor brownColor];

    [self.view addSubview:view3];

    view3.tag=102;

    [view3 release];

    //view4

    UIView *view4=[[UIView alloc]initWithFrame:CGRectMake_4];

    view4.backgroundColor=[UIColor redColor];

    [self.view addSubview:view4];

    view4.tag=103;

    [view4 release];

    //view5

    UIView *view5=[[UIView alloc]initWithFrame:CGRectMake_5];

    view5.backgroundColor=[UIColor lightGrayColor];

    [self.view addSubview:view5]; 

    view5.tag=104;

    [view5 release];

    //view6

    UIView *view6=[[UIView alloc]initWithFrame:CGRectMake_6];

    view6.backgroundColor=[UIColor blueColor];

    [self.view addSubview:view6]; 

    view6.tag=105;

    [view6 release];

    //view7

    UIView *view7=[[UIView alloc]initWithFrame:CGRectMake_7];

    view7.backgroundColor=[UIColor magentaColor];

    [self.view addSubview:view7];  

    view7.tag=106;

    [view7 release];


//    self.array=[[NSMutableArray alloc]initWithObjects:view7.backgroundColor,view6.backgroundColor,view5.backgroundColor,view4.backgroundColor,view3.backgroundColor,view2.backgroundColor,view1.backgroundColor, nil];


    

 [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(read) userInfo:nil repeats:YES];



}


- (void)read

{

    for (  int i=0; i<7; i++) {

        UIView *view = [self.view viewWithTag:100+i];      

        

        if (view.frame.origin.x+20>150)

        {

            view.frame = CGRectMake(30, 30, 260, 400);

            

            [self.view insertSubview:view atIndex:1];

            

        } else

        {

            

            view.frame = CGRectMake(view.frame.origin.x+20, view.frame.origin.y+20, view.frame.size.width-40, view.frame.size.height-40); 

        }

    }

    

    

}


- (void)viewDidUnload

{

    [super viewDidUnload];

    // Release any retained subviews of the main view.

    // e.g. self.myOutlet = nil;

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    // Return YES for supported orientations

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}


@end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值