-(Void) viewDidLoad {
[Super viewDidLoad];
FlakeImage = [UIImage imageNamed: @ "flake.png"];
[NSTimer scheduledTimerWithTimeInterval :( 0.05) target: self selector: @ selector (play) userInfo: nil repeats: YES];
}
-(BOOL) shouldAutorotateToInterfaceOrientation :( UIInterfaceOrientation) interfaceOrientation {
Return (interfaceOrientation = UIInterfaceOrientationLandscapeLeft );
}
-(Void) play {
UIImageView * flakeView = [[UIImageView alloc] initWithImage: flakeImage];
Int startX = round (random () % 1024 );
Int endX = round (random () % 1024 );
Double scale = 1/round (random () % 100) + 1.0;
Double speed = 1/round (random () % 100) + 1.0;
FlakeView. frame = CGRectMake (startX,-100.0, 25.0 * scale, 25.0 * scale );
FlakeView. alpha = 0.55;
[Self. view addSubview: flakeView];
[UIView beginAnimations: nil context: flakeView];
[UIView setAnimationDuration: 5 * speed];
FlakeView. frame = CGRectMake (endX, 768.0, 25.0 * scale, 25.0 * scale );
[UIView setAnimationDidStopSelector: @ selector (onAnimationComplete: finished: context :)];
[UIView setAnimationDelegate: self];
[UIView commitAnimations];
}
-(Void) onAnimationComplete :( NSString *) animationID finished :( NSNumber *) finished context :( void *) context {
UIImageView * flakeView = context;
[FlakeView removeFromSuperview];
[FlakeView release];
}
-(Void) viewDidLoad {
[Super viewDidLoad];
FlakeImage = [UIImage imageNamed: @ "flake.png"];
[NSTimer scheduledTimerWithTimeInterval :( 0.05) target: self selector: @ selector (play) userInfo: nil repeats: YES];
}
-(BOOL) shouldAutorotateToInterfaceOrientation :( UIInterfaceOrientation) interfaceOrientation {
Return (interfaceOrientation = UIInterfaceOrientationLandscapeLeft );
}
-(Void) play {
UIImageView * flakeView = [[UIImageView alloc] initWithImage: flakeImage];
Int startX = round (random () % 1024 );
Int endX = round (random () % 1024 );
Double scale = 1/round (random () % 100) + 1.0;
Double speed = 1/round (random () % 100) + 1.0;
FlakeView. frame = CGRectMake (startX,-100.0, 25.0 * scale, 25.0 * scale );
FlakeView. alpha = 0.55;
[Self. view addSubview: flakeView];
[UIView beginAnimations: nil context: flakeView];
[UIView setAnimationDuration: 5 * speed];
FlakeView. frame = CGRectMake (endX, 768.0, 25.0 * scale, 25.0 * scale );
[UIView setAnimationDidStopSelector: @ selector (onAnimationComplete: finished: context :)];
[UIView setAnimationDelegate: self];
[UIView commitAnimations];
}
-(Void) onAnimationComplete :( NSString *) animationID finished :( NSNumber *) finished context :( void *) context {
UIImageView * flakeView = context;
[FlakeView removeFromSuperview];
[FlakeView release];
}
Example:
Author: jsntghf