两朵飘动的小云

代码记录:


@interface ViewController (){

    UIImageView * v1;

    UIImageView * v2;

}


@end


@implementation ViewController



- (void)viewDidLoad {

    [super viewDidLoad];

    //[self CloudAinimate];

    [self bgAnimate];

    // Do any additional setup after loading the view, typically from a nib.

}



-(void)bgAnimate {

    if (v1==nil) {

        v1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"cloud"]];

        v2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"cloud2"]];

        v1.alpha = v2.alpha = 0;

        

        v1.frame = CGRectMake(20, -275, 1024, 520);

        v2.frame = CGRectMake(120, -290, 1024, 520);

        

        

        [self.view addSubview:v1];

        [self.view addSubview:v2];

    }

    

    NSLog(@"bganimate");

    float t = 32.0f;

    [UIView animateWithDuration:4.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

        //淡入出现

        v1.frame = CGRectMake(0, -280, 1024, 520);

        v2.frame = CGRectMake(-512+128, -300, 1024, 520);

        v1.transform = CGAffineTransformMakeScale(1.0, 1.0);

        v2.transform = CGAffineTransformMakeScale(1.0, 1.0);

        // v1.alpha = 0.2;

        // v2.alpha = 0.2;

        v1.alpha = 0.8;

        v2.alpha = 0.8;

    } completion:^(BOOL finished){

        [UIView animateWithDuration:t delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

            //v1向放大快速右移动, v2缩小慢速

            v1.frame = CGRectMake(-512, -350, 1024, 520);

            v2.frame = CGRectMake(-1204, -250, 1024, 520);

            v1.transform = CGAffineTransformMakeScale(1.2, 1.2);

            v2.transform = CGAffineTransformMakeScale(0.8, 0.8);

            //  v1.alpha = 0.2;

            //  v2.alpha = 0.2;

            v1.alpha = 0.8;

            v2.alpha = 0.8;

        } completion:^(BOOL finished){

            v2.frame = CGRectMake(1024, -250, 1024, 520);

            [UIView animateWithDuration:t delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

                //v1向淡出, v2慢速

                v1.frame = CGRectMake(-1024, -300, 1024, 520);

                v2.frame = CGRectMake(512-128, -350, 1024, 520);

                v1.transform = CGAffineTransformMakeScale(1.4, 1.4);

                v2.transform = CGAffineTransformMakeScale(1.0, 1.0);

                //v1.alpha = 0.1;

                // v2.alpha = 0.15;

                

                v1.alpha = 0.5;

                v2.alpha = 0.55;

            } completion:^(BOOL finished){

                v1.frame = CGRectMake(1024, -350, 1024, 520);

                v1.transform = CGAffineTransformMakeScale(0.6, 0.6);

                [UIView animateWithDuration:t delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

                    //v1向右侧进入, v2快速左侧移动

                    v1.frame = CGRectMake(512, -300, 1024, 520);

                    v2.frame = CGRectMake(0, -300, 1024, 520);

                    v1.transform = CGAffineTransformMakeScale(0.8, 0.8);

                    v2.transform = CGAffineTransformMakeScale(1.2, 1.2);

                    // v1.alpha = 0.15;

                    // v2.alpha = 0.1;

                    

                    v1.alpha = 0.5;

                    v2.alpha = 0.55;

                } completion:^(BOOL finished){

                    

                    [UIView animateWithDuration:t delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

                        //v1向右侧进入, v2快速左侧移动

                        v1.frame = CGRectMake(20, -250, 1024, 520);

                        v2.frame = CGRectMake(-512+108, -350, 1024, 520);

                        v1.transform = CGAffineTransformMakeScale(0.9, 0.9);

                        v2.transform = CGAffineTransformMakeScale(1.1, 1.1);

                        // v1.alpha = 0.2;

                        //v2.alpha = 0.1;

                        v1.alpha = 0.8;

                        v2.alpha = 0.4;

                    } completion:^(BOOL finished){

                        // if (__userToken) return;

                       

                    }];

                }];

                

            }];

        }];

    }];

    

    

}



-(void)CloudAinimate

{

    if (v1==nil) {

        v1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cloud.png"]];

        v2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cloud2.png"]];

        v1.alpha = v2.alpha = 0;

        

        v1.frame = CGRectMake(0, 0, 500, 300);

        v2.frame = CGRectMake(0, 0, 500, 400);

        

        

        [self.view addSubview:v1];

        [self.view addSubview:v2];

        

        [UIView animateWithDuration:4.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

            

            v1.alpha = 1;

            v2.alpha = 1;

        } completion:^(BOOL finished){

            

            

        }];

        

        

    }

    

    v1.alpha = 1;

    v2.alpha = 1;

    

    NSLog(@"CloudAinimate");

    [UIView animateWithDuration:40.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

        //淡入出现

        

        CGRect t = v1.frame;

        if( t.origin.x == 0 )

        {

            v1.frame = CGRectMake(-1024, 300, 1024, 768);

            v2.frame = CGRectMake(0, 300, 1024, 768);

        }

        else

        {

            v1.frame = CGRectMake(0, 300, 1024, 768);

            v2.frame = CGRectMake(-1024, 300, 1024, 768);

        }

    }completion:^(BOOL finished)

     {

         CGRect t = v1.frame;

         if(t.origin.x == -1024 )

         {

             v1.frame = CGRectMake(1024, 300, 1024, 768);

         }

         else

         {

             v2.frame = CGRectMake(1024, 300, 1024, 768);

             

         }

         

     }];

    

    

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值