Float snowflake animation, float snowflake

Source: Internet
Author: User

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

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.