UIImageView更改背景颜色和setImage在动画期间不起作用

isa*_*ent 4 iphone cocoa-touch objective-c uiimageview ios

正如标题所述,这很奇怪,您同意吗?

所以,如果有人找到您的密码

imageView.backgroundColor = [UIColor greenColor]; 
Run Code Online (Sandbox Code Playgroud)

要么

imageView.image = [UIImage imageName:@"angryBird"];" 
Run Code Online (Sandbox Code Playgroud)

不工作。请注意,如果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"];
Run Code Online (Sandbox Code Playgroud)

同样在选择器方法中,当执行performSelector:withObject:afterDey:1.0s时,您也需要stopAnimating,然后设置Image或更改背景色。

Vin*_*ngh 5

动画完成后,尝试更改背景颜色并更改图像。它只会为您工作。