我正在使用[UIView animateWithDuration ...]为了显示我的应用程序的每个页面的文本。每个页面都有自己的文字。我在页面间滑动浏览。我在显示页面后使用1秒溶解效果使文本消失。如何在完成之前中断UIView动画?
下面是问题:如果我在1秒内(在此期间文本正在淡入)中滑动,则会在下一页出现并且2个文本重叠(前一个和当前)时完成动画。
我想要实现的解决方案是中断动画,如果我碰巧在其发生时刷卡。我无法做到这一点。 [self.view.layer removeAllAnimations];不适合我。
这里是我的动画代码:
- (void) replaceContent: (UITextView *) theCurrentContent withContent: (UITextView *) theReplacementContent {
theReplacementContent.alpha = 0.0;
[self.view addSubview: theReplacementContent];
theReplacementContent.alpha = 0.0;
[UITextView animateWithDuration: 1.0
delay: 0.0
options: UIViewAnimationOptionTransitionCrossDissolve
animations: ^{
theCurrentContent.alpha = 0.0;
theReplacementContent.alpha = 1.0;
}
completion: ^(BOOL finished){
[theCurrentContent removeFromSuperview];
self.currentContent = theReplacementContent;
[self.view bringSubviewToFront:theReplacementContent];
}];
}
你们是否知道如何使这项工作?你知道解决这个问题的其他方法吗?
可能重复[取消UIView动画?](http://stackoverflow.com/questions/554997/cancel-a-uiview-animation) – matt
你尝试发送'removeAllAnimations'到'CurrentContent.layer'和' theReplacementContent.layer'? –
@matt,虽然 – Armand