1
我試圖堆疊兩個動畫。我在兩張圖片的代碼中使用相同的UIImage。 我首先確定(第一行)要加載的圖像。嘗試堆疊到UIView註釋
NSString *imageName = (self._handleToSectionModel.calculatorState == CALCULATOR_OPENED)?
[NSString stringWithString:@"1_dg_please_see_warning_2lines.png"] :
[NSString stringWithString:@"1_dg_warnings_landing_page.png"];
我想淡出當前圖像,並加載新的圖像和消除它。顯然,當我 執行這一點,只有真正動畫第二個。將動畫 堆疊到相同視圖的正確方法是什麼,以便它們都完全運行?
UIImage *image = [UIImage imageNamed:imageName];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f];
self.warningImage.alpha = 0.0f;
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f];
self.warningImage.alpha = 1.0f;
self.warningImage.image = image;
[UIView commitAnimations];
編輯/ UPDATE: 解決:
[UIView animateWithDuration:1.0 animations:^{ self.warningImage.alpha = 0.0f; } completion:^(BOOL finished){
[UIView animateWithDuration:1.0 animations:^{ self.warningImage.alpha = 1.0f; self.warningImage.image = image; } completion:^(BOOL finished){}];
}];
由於鏈接在我的評論!
哇,剛發現這個:http://stackoverflow.com/questions/3849460/best-way-to-perform-several-sequential-uiview-animations – 2011-05-19 16:59:03