- (void)generateSnow
{
//1. 创建雪花对象
UIImageView *snow = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"snow.png"]];
snow.tag = self.count;
int size = arc4random() % MAX_SIZE + MAX_SIZE;
snow.frame = CGRectMake(arc4random()%320, -20, size, size);
[self.view addSubview:snow];
self.count++;
//2. 创建动画
//2.1 开始动画
[UIView beginAnimations:[NSString stringWithFormat:@"%d", self.count] context:nil];
//2.2 设置动画各种属性
[UIView setAnimationDuration:arc4random()%MAX_DURATIOIN + 2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
//2.3 设置动画的结束状态
int offsetX = arc4random()%MAX_OFFSET_X - 50;
snow.center = CGPointMake( snow.center.x + offsetX,self.view.bounds.size.height - 30);
snow.transform = CGAffineTransformMakeRotation(M_PI*(arc4random()%180/180.0));
//2.3.2 设置动画的委托
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(disappearAnimate:)];
//2.4 提交动画
[UIView commitAnimations];
}