IOS 雪花飘落效果

jopen 11年前
        UIImageView *peach2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower2"]];//声明一个UIImageView对象,用来添加图片            peach2.alpha = 0.8;//设置该view的alpha为0.5,半透明的            int xx = round(random()%2000);//随机得到该图片的x坐标            int yx = round(random()%2000);//这个是该图片移动的最后坐标x轴的            int sx = random()%50+10;//这个是定义雪花图片的大小            int spx = random()%5;//这个是速度            peach2.frame = CGRectMake(-xx, -10, sx, sx);//雪花开始的大小和位置            [view_bottom addSubview:peach2];//添加该view            [UIView animateWithDuration:10*spx                             animations:^{                                 peach2.frame = CGRectMake(yx, self.view.frame.size.height, sx, sx);//设定该雪花最后的消失坐标                             } completion:^(BOOL finished) {                                 [peach2 removeFromSuperview];                             }];