我正在使用 [UIView animateWithDuration... ] 来为我的应用程序的每个页面显示文本。每个页面都有自己的文本。我正在滑动以在页面之间导航。我正在使用 1 秒溶解效果让文本在页面显示后淡入。
这是问题所在:如果我在那 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];
}];
}
你们知道如何进行这项工作吗?你知道解决这个问题的其他方法吗?