我目前使用这个核心动画; (iOS 5中,ARC)CoreAnimation:将动画对象转移到下一个UIViewController
- (void)onTimer
{
// build a view from our image
UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage];
// use the random() function to randomize up our flake attributes
int startX = round(random() % 320);
int endX = startX; //round(random() % 320);
double scale = 1/round(random() % 100) + 1.0;
double speed = 1/round(random() % 100) + 1.0;
// set the flake start position
flakeView.frame = CGRectMake(startX, -100.0, 25.0 * scale, 25.0 * scale);
flakeView.alpha = 0.8;
// put the flake in our main view
[self.view addSubview:flakeView];
[self.view sendSubviewToBack:flakeView];
[UIView beginAnimations:nil context:(__bridge void*)flakeView];
// set up how fast the flake will fall
[UIView setAnimationDuration:10 * speed];
// set the postion where flake will move to
flakeView.frame = CGRectMake(endX, 500.0, 25.0 * scale, 25.0 * scale);
// set a stop callback so we can cleanup the flake when it reaches the
// end of its animation
[UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
- (void)onAnimationComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
UIImageView *flakeView = (__bridge UIImageView*)context;
[flakeView removeFromSuperview];
flakeView = nil;
}
火;
[NSTimer scheduledTimerWithTimeInterval:(0.3) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
有了这段代码,就有10个雪片被呈现,掉下来。
借助此代码以及一些自定义视图转换,我正在尝试使导航操作变得流畅。问题是我无法找到正确的方法将这些(动画)上下文转移到下一个UIViewController
,所以所有的动画片雪花将继续保持他们离开的位置,并且下一个UIViewController
的NSTimer
将激发新的动画。
任何帮助和建议将appriciated。
您不清楚您尝试传输的内容。你想把实际的图像视图转移到下一个控制器吗?描述你正在寻找的视觉效果可能很有用。顺便说一句,你根本不应该使用这种动画方法。您应该在iOS 4或更高版本中使用基于块的方法。 – rdelmar 2013-03-16 04:58:07