IOS 雪花飘落效果
2018-07-20 来源:open-open
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];
}];
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:将颜色转换为其反色的PHP代码
最新资讯
热门推荐