gar*_*hdn 5 iphone animation objective-c uiviewcontroller ios
我有许多动画在加载我的根视图控制器时自动启动.这些动画包括在内viewDidLoad.当我导航到我的下一个视图控制器并返回到根视图控制器时,所有动画都已停止.当我按下"主页"按钮然后返回到视图时,会出现相同的行为.
我敢肯定我在这里遗漏了一些非常基本的东西但是会感激任何帮助.谢谢.
编辑1:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self beeBobbing];
//animate the butterfly oscillating
[self butterflyOscillate];
}
-(void) beeBobbing
{
[UIView animateWithDuration:1.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction ) animations:^{
CGPoint bottomPoint = CGPointMake(215.0, 380.0);
imgBee.center = bottomPoint;
} completion:^(BOOL finished) {
}];
}
Run Code Online (Sandbox Code Playgroud)
编辑2:在视图之间切换时,这种类型的动画似乎重新启动:
-(void) animateClouds
{
[UIView animateWithDuration:30.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
CGPoint leftScreenCenter = CGPointMake(-420.0, 119.0);
imgClouds.center = leftScreenCenter;
} completion:^(BOOL finished) {
CGPoint rightScreenCenter = CGPointMake(1450.0, 119.0);
imgClouds.center = rightScreenCenter;
[UIView animateWithDuration:40.0f delay:0 options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionRepeat) animations:^{
CGPoint leftScreenCenter = CGPointMake(-420.0, 119.0);
imgClouds.center = leftScreenCenter;
} completion:^(BOOL finished) {
}];
}];
}
Run Code Online (Sandbox Code Playgroud)