首页 > 移动平台 > 详细

iOS开发——雪花下落

时间:2016-06-30 17:46:09      阅读:185      评论:0      收藏:0      [点我收藏+]

用帧动画实现

-(void)goCome
{
    timer =[NSTimer  scheduledTimerWithTimeInterval:0.6 target:self selector:@selector(go) userInfo:nil repeats:YES];
}
-(void)go
{
//动画效果
        UIImageView *iv = [[UIImageView alloc]init];
        int a = arc4random()%51;//雪花大小随机(0~50)
        iv.frame = CGRectMake(arc4random()%370 - 50, -50, a, a);
        iv.image = [UIImage imageNamed:@"3"];
        [self.view addSubview:iv];
        
        [UIView beginAnimations:nil context:(__bridge void *)(iv)];
        [UIView setAnimationDuration:3];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
        iv.frame = CGRectMake(arc4random()%370 - 50, 460, a, a);
        [UIView commitAnimations];
  
}
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context//到底部消除
{
    UIImageView *image = (__bridge UIImageView *)context;
    [image removeFromSuperview];
}

 

iOS开发——雪花下落

原文:http://www.cnblogs.com/qinxiaoguang/p/5630440.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!