我目前有一個默認的循環動畫,當視圖出現時淡入淡出,當數據的背景處理完成時,它將停止當前動畫加載新的動畫,根據新的圖片。如何停止循環動畫並用新值再次調用
我不能看到停止使用[self.view.layer removeAllAnimations];
[self.imageViewBottom.layer removeAllAnimations];
[self.imageViewTop.layer removeAllAnimations];
-(void)nextAnimation:(float)previousWidth {
//picture loop
imageViewTop.image = imageViewBottom.image;
imageViewBottom.image = [imageArray objectAtIndex:[imageArray count] - 1];
[imageArray insertObject:imageViewBottom.image atIndex:0];
[imageArray removeLastObject];
imageViewTop.alpha = 1.0;
imageViewBottom.alpha = 0.0;
[UIView animateWithDuration:4.0
animations:^{
imageViewTop.alpha = 0.0;
imageViewBottom.alpha = 1.0;
}
completion:^(BOOL completed){
[self nextAnimation:stringsize.width];
}
];
-(void)foundSetup
{
//[imageViewTop removeFromSuperview];
//[imageViewBottom removeFromSuperview];
//[buttonCaption removeFromSuperview];
[self.view.layer removeAllAnimations];
[self.imageViewBottom.layer removeAllAnimations];
[self.imageViewTop.layer removeAllAnimations];
//[self.imageArray removeAllObjects];
//self.imageArray = foundImageArray;
}
'[imageViewTop.layer removeAllAnimations];'和'[imageViewBottom.layer removeAllAnimations];'? – Till
@Till,你應該將其作爲答案發布。 self.view沒有動畫,因此刪除它們毫無意義。 – jrturton
感謝直到,還沒有動畫 – Desmond