VIew移动做成动画效果    这种动画效果没有中间的位移

 

可以添加动画的View属性center,frame,alpha,transform , backgroundColor

 

//继续做消失的动画

        [UIView animateWithDuration:1 animations:^{

            

            iv.alpha = 0;

            

        } completion:^(BOOL finished) {

            //完成动画后执行 可以继续添加

            [iv removeFromSuperview];

        }];

        

 

 

 

 

- (void)viewDidLoad {

    [super viewDidLoad];

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

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

}

-(void)addSnow{

    int size = arc4random()%10+10;

    UIImageView *iv = [[UIImageViewalloc]initWithFrame:CGRectMake(arc4random()%(320-size), -size, size, size)];

    iv.p_w_picpath = [UIImagep_w_picpathNamed:@"snow"];

    [self.view addSubview:iv];

    

    int time = arc4random()%4+1;

    //添加移动动画

    [UIView animateWithDuration:time animations:^{

        //移动的终点位置

        iv.center = CGPointMake(iv.center.x, 568);

        //图形改变终点形状

        iv.transform = CGAffineTransformRotate(iv.transform, (arc4random()%360)/180.0*M_PI);

    } completion:^(BOOLfinished) {

        

        

        //继续做雪花消失的动画

        [UIView animateWithDuration:1 animations:^{

            

            iv.alpha = 0;

            

        } completion:^(BOOL finished) {

            

            [iv removeFromSuperview];

        }];

        

        

    }];

    

    

}