正如標題所說,這很奇怪,你同意嗎?UIImageView更改背景顏色和setImage在動畫過程中不起作用
因此,如果有人發現你的代碼
imageView.backgroundColor = [UIColor greenColor];
或
imageView.image = [UIImage imageName:@"angryBird"];"
不工作。請注意,如果您的imageView是動畫,或者動畫是否已被刪除。
---------- 的回答以下 ---------------
只要停止您設置圖像之前的動畫和改變的背景動畫UIImageView。
UIImageView* imageView = [UIImageView alloc] init];
//......do sth. like setFrame ...
imageView.images = [NSArray arrayWithObjects....]; // set the animation images array
imageView.animationDuration = 1.0;
[imageView startAnimating];
//......do sth.
[imageView stopAnimating]; // **** do not forget this!!!!! ****
imageView.backgroundColor = [UIColor greenColor];
imageView.image = [UIImage imageName:@"angryBird"];
當你performSelector:withObject:afterDey:1.0秒,在選擇方法,也需要stopAnimating過,然後setImage或改變背景顏色。
請讓我知道你的代碼是否工作。謝謝 – chandan
在分配圖像名稱爲angryBird之前,請仔細檢查您的拼寫 – chandan
謝謝。這不是框架的問題。在動畫停止之前,我改變了imageView的背景色,最好的方式是在動畫停止後改變背景色。或者,另一種方法是停止其動畫,然後更改背景顏色。 – isaacselement