[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
- (void)handleAction:(CADisplayLink *)displayLink{
UIImage *image = [UIImage imageNamed:@"雪花"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
CGFloat scale = arc4random_uniform(60) / 100.0;
imageView.transform = CGAffineTransformMakeScale(scale, scale);
CGSize winSize = self.view.bounds.size;
CGFloat x = arc4random_uniform(winSize.width);
CGFloat y = - imageView.frame.size.height;
imageView.center = CGPointMake(x, y);
[self.view addSubview:imageView];
[UIView animateWithDuration:arc4random_uniform(10) animations:^{
CGFloat toX = arc4random_uniform(winSize.width);
CGFloat toY = imageView.frame.size.height * 0.5 + winSize.height;
imageView.center = CGPointMake(toX, toY);
/**雪花旋转*/
imageView.transform = CGAffineTransformRotate(imageView.transform, arc4random_uniform(M_PI * 2));
imageView.alpha = 0.5;
} completion:^(BOOL finished) {
/**动画结束见图片移除*/
[imageView removeFromSuperview];
}];
// NSLog(@"%ld",self.displayLink.frameInterval);
// NSLog(@"%lf",self.displayLink.duration);
//
}