码迷,mamicode.com
首页 > 其他好文 > 详细

两个色块做的红绿灯

时间:2014-08-20 21:04:52      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   ar   div   cti   

#import "ViewController.h"

@interface ViewController ()
{
    UIView *view;
    UIView *view0;
    int i;
}

@end

@implementation ViewController
            
- (void)viewDidLoad {
    [super viewDidLoad];
    view=[[UIView alloc]initWithFrame:CGRectMake(100, 100, 50, 50)];
    view0=[[UIView alloc]initWithFrame:CGRectMake(200, 100, 50, 50)];
    view.backgroundColor=[UIColor redColor];
    view0.backgroundColor=[UIColor greenColor];
    [self.view addSubview:view];
    [self.view addSubview:view0];
    [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(didclick:) userInfo:nil repeats:YES];

}


- (IBAction)didclick:(id)sender
{
    
//    [UIView animateWithDuration:5 delay:4 options: UIViewAnimationOptionCurveEaseInOut                       animations:^{} completion:(void (^)(BOOL finished))completion{
//        }];
    
    [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
        NSLog(@"XXXXXXX");
        if (i%2==0)
        {view.frame=CGRectMake(100, 100, 100, 100);}
        else
        {
            view0.frame=CGRectMake(200, 100, 100, 100);
        }
    } completion:^(BOOL finished) {
        NSLog(@"FINISH");
        view.frame=CGRectMake(100, 100, 50, 50);
        view0.frame=CGRectMake(200, 100, 50, 50);
        i++;
    }];


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 

两个色块做的红绿灯,布布扣,bubuko.com

两个色块做的红绿灯

标签:style   blog   color   os   io   ar   div   cti   

原文地址:http://www.cnblogs.com/sunxiang1991/p/3925450.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!