IOS 雪花飘落效果

2015-02-02 0 669
IOS 雪花飘落效果
        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];  
                         }];  

遇见资源网 objective-c IOS 雪花飘落效果 http://www.ox520.com/16104.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务