1

didSelectRowAtIndexPathの2つの点滅画像でtableviewcellの背景画像をアニメーション化したい。次のコードを使用できますが、背景に 1 つの画像が表示されます。ただし、点滅する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];

アニメーションの各フレームをプロジェクトに含める必要があります。

また、UITableViewCellの imageView プロパティを使用した方がよいのではないでしょうか? そうすれば、セルの左側にアニメーションが表示され、テキストやセルの他の部分に干渉することはありません...

于 2012-06-26T17:04:27.760 に答える