1

我想用 didSelectRowAtIndexPath 上的两个闪烁图像为 tableviewcell 背景图像设置动画。我们可以使用以下代码,但它会在背景中显示一张图像。但是我想要像闪烁的图像一样的gif。

cell.backgroundView = [ [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"correctAnswer.png"]]autorelease];  
4

1 回答 1

0

UIImageView 有能力用animationImages属性做动画。

UIImageView* imgView = [[[UIImageView alloc] init] autorelease];
imgView.animationImages = [NSArray arrayWithObjects:
    [UIImage imageNamed:@"correctAnswer1.png"],
    [UIImage imageNamed:@"correctAnswer2.png"], nil];

imgView.animationDuration = 0.5;
cell.backgroundView = imgView;
[imgView startAnimating];

您需要在项目中包含动画的每一帧,correctAnswer1.png、correctAnswer2.png 等...

UITableViewCell另外,使用'imageView 属性不是更好吗?这样,您将在单元格的左侧获得动画,并且不会干扰文本或单元格的任何其他部分...

于 2012-06-26T17:04:27.760 回答