Float snowflake animation, float snowflake
The implementation of the snow float Animation:
1. Snowflake images.
2. The snow action is implemented by the view layer, and a falling action is implemented by the view layer.
3. Apply the algorithm to implement the random time, and then create the corresponding snowflake to implement the descent.
Some code:
-(Void) ontime {
UIImageView * view;
View = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "xuehua.jpg"];
View. alpha = 0.5;
Int x = round (random () % 320 );
Int y = round (random () % 320 );
Int s = round (random () % 15) + 10;
Int sp = 1/round (random () % 100) + 1;
View. frame = CGRectMake (x, y-250, s, s );
[Self. view addSubview: view];
[UIView beginAnimations: nil context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration: 10 * sp];
View. frame = CGRectMake (x, 500, s, s );
[UIView setAnimationDelegate: self];
[UIView commitAnimations];
}
Address: https://github.com/ChangYulong/SnowDemo