@interface ViewController (){ UIImage *image;}- (IBAction)didAction:(id)sender;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor cyanColor]; //雪花图片 image = [UIImage imageNamed:@"iconfont-xuehua"]; //启动定时器 [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showTime) userInfo:nil repeats:YES]; // Do any additional setup after loading the view, typically from a nib.}- (void)showTime { //创建雪花 UIImageView *imageV = [[UIImageView alloc] initWithImage:image]; //添加 [self.view addSubview:imageV]; NSInteger startX = arc4random()%356 + 10; //雪花开始位置 imageV.frame = CGRectMake(startX, 50, 50, 50); //动画 [UIView animateWithDuration:2 animations:^{ //雪花下落位置 imageV.frame = CGRectMake(startX, self.view.frame.size.height, 30, 30); } completion:^(BOOL finished) { //动画完成移除雪花 [imageV removeFromSuperview]; }]; }- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}- (IBAction)didAction:(id)sender { WebViewController *web = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil]; [self.navigationController pushViewController:web animated:YES];}@end