标签:
用帧动画实现
-(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]; }
标签:
原文地址:http://www.cnblogs.com/qinxiaoguang/p/5630440.html