我正在尝试重新启动一个动画,一旦你最小化应用程序然后重新打开它就会停止。因此,当我从Xcode开始使用新应用程序时,它的动画效果很好,精灵飙升了。向下......但是当我用底部按钮关闭应用程序并打开它时,应用程序返回原来的y坐标然后停止。
函数genie_animation工作正常,就像我在下面的活动函数中调用了一个NSLOG而且它有效,但是动画没有。
我在applicationDidBecomeActive
:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
ViewController *vc;
vc = [[ViewController alloc] init];
[vc genie_animation];
}
然后这是我的动画代码:
-(void)genie_animation {
CGRect frm_up = tpl_genie.frame;
frm_up.origin.y -= 4;
[UIImageView animateWithDuration:1
delay:0.0
options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState
animations:^{
tpl_genie.frame = frm_up;
}
completion:nil
];
}