技术:创建一个由UIImage组成的图片数组,然后按照序列逐帧的播放这些图片,这样看起来就类似一个动画效果:
参考代码:
-(IBAction)playButton:(id)sender;
{
CGRect rect = CGRectMake(20, 20, 100, 100);
UIImageView *m_View = [[[UIImageView alloc] initWithFrame:rect] autorelease];
UIImage *image1 = [UIImage imageNamed:@"picTVcar1.png"];
UIImage *image2 = [UIImage imageNamed:@"picTVcar2.png"];
UIImage *image3 = [UIImage imageNamed:@"picTVcar3.png"];
UIImage *image4 = [UIImage imageNamed:@"picTVcar4.png"];
UIImage *image5 = [UIImage imageNamed:@"picTVcar5.png"];
UIImage *image6 = [UIImage imageNamed:@"picTVcar6.png"];
UIImage *image7 = [UIImage imageNamed:@"picTVcar7.png"];
UIImage *image8 = [UIImage imageNamed:@"picTVcar8.png"];
UIImage *image9 = [UIImage imageNamed:@"picTVcar9.png"];
UIImage *image10 = [UIImage imageNamed:@"picTVcar10.png"];
UIImage *image11 = [UIImage imageNamed:@"picTVcar11.png"];
UIImage *image12 = [UIImage imageNamed:@"picTVcar12.png"];
NSArray *imageArray = [NSArray arrayWithObjects:
image1,
image2,
image3,
image4,
image5,
image6,
image7,
image8,
image9,
image10,
image11,
image12,
nil];
m_View.animationImages = imageArray;
m_View.animationDuration = 1.0;
m_View.animationRepeatCount = 0;
[self.view addSubview:m_View];
[m_View startAnimating];
}
THE END !