跑马灯

#import "MainViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

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

{

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

    if (self) {

        // Custom initialization

        

        self.timer = [NSTimer scheduledTimerWithTimeInterval:0.8 target:selfselector:@selector(viewDidLoad) userInfo:nil repeats:YES];

        self.color = [[NSMutableArray alloc] initWithObjects:[UIColorredColor], [UIColor orangeColor], [UIColor yellowColor], [UIColorgreenColor], [UIColor cyanColor], [UIColor blueColor], [UIColor purpleColor],nil];

        [self.color release];

        self.text = [[NSMutableArray alloc] initWithObjects:@"栋", @"栋",@"是", @"大", @"逗", @"逼", @"是", nil];

        [self.text release];

    }

    return self;

}


- (void)viewDidLoad

{

    [super viewDidLoad];

    // Do any additional setup after loading the view.

    [self.color insertObject:self.color[0] atIndex:7];

    [self.color removeObjectAtIndex:0];

    

//    [self.color insertObject:self.color[6] atIndex:0];

//    [self.color removeObjectAtIndex:7];

    

    [self.text insertObject:self.text[0] atIndex:7];

    [self.text removeObjectAtIndex:0];

    

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320,480)];

    view.backgroundColor = self.color[0];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, 40,30)];

    label.text = self.text[0];

    [view addSubview:label];

    [label release];

    [self.view addSubview:view];

    [view release];

    

    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(40, 0, 280,480)];

    view1.backgroundColor = self.color[1];

    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, 40,30)];

    label1.text = self.text[1];

    [view1 addSubview:label1];

    [label1 release];

    [self.view addSubview:view1];

    [view1 release];

    

    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(80, 0, 240,480)];

    view2.backgroundColor = self.color[2];

    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, 40,30)];

    label2.text = self.text[2];

    [view2 addSubview:label2];

    [label2 release];

    [self.view addSubview:view2];

    [view2 release];

    

    UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(120, 0, 200,480)];

    view3.backgroundColor = self.color[3];

    UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, 40,30)];

    label3.text = self.text[3];

    [view3 addSubview:label3];

    [label3 release];

    [self.view addSubview:view3];

    [view3 release];

    

    UIView *view4 = [[UIView alloc] initWithFrame:CGRectMake(160, 0, 160,480)];

    view4.backgroundColor = self.color[4];

    UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, 40,30)];

    label4.text = self.text[4];

    [view4 addSubview:label4];

    [label4 release];

    [self.view addSubview:view4];

    [view4 release];

    

    UIView *view5 = [[UIView alloc] initWithFrame:CGRectMake(200, 0, 120,480)];

    view5.backgroundColor = self.color[5];

    UILabel *label5 = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, 40,30)];

    label5.text = self.text[5];

    [view5 addSubview:label5];

    [label5 release];

    [self.view addSubview:view5];

    [view5 release];

    

    UIView *view6 = [[UIView alloc] initWithFrame:CGRectMake(240, 0, 80,480)];

    view6.backgroundColor = self.color[6];

    UILabel *label6 = [[UILabel alloc] initWithFrame:CGRectMake(0, 130, 80,50)];

    label6.text = self.text[6];

    label6.font = [UIFont systemFontOfSize:50];

    [view6 addSubview:label6];

    [label6 release];

    [self.view addSubview:view6];

    [view6 release]; 

}

- (void)dealloc

{

    [_timer release];

    [_color release];

    [super dealloc];

}

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值