IOS:.png的动画

时间:2011-10-10 15:47:21

标签: ios xcode animation png

我想为不同版本的png制作动画;然后我有三个版本的这个png ...更深的版本,中等深色版本和克莱尔版本。在我的动画中,我想做这种类型的动画

黑暗 - >中等黑暗 - >克莱尔 - >中等黑暗 - >黑暗 - >中等黑暗 - > .....

有可能吗?

1 个答案:

答案 0 :(得分:17)

听起来你想要动画uiimageview

// create the view that will execute our animation
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];

// load all the frames of our animation
campFireView.animationImages = [NSArray arrayWithObjects:    
                            [UIImage imageNamed:@"campFire01.gif"],
                            [UIImage imageNamed:@"campFire02.gif"],
                            [UIImage imageNamed:@"campFire03.gif"],
                            [UIImage imageNamed:@"campFire04.gif"],
                            [UIImage imageNamed:@"campFire05.gif"],
                            [UIImage imageNamed:@"campFire06.gif"],
                            [UIImage imageNamed:@"campFire07.gif"],
                            [UIImage imageNamed:@"campFire08.gif"],
                            [UIImage imageNamed:@"campFire09.gif"],
                            [UIImage imageNamed:@"campFire10.gif"],
                            [UIImage imageNamed:@"campFire11.gif"],
                            [UIImage imageNamed:@"campFire12.gif"],
                            [UIImage imageNamed:@"campFire13.gif"],
                            [UIImage imageNamed:@"campFire14.gif"],
                            [UIImage imageNamed:@"campFire15.gif"],
                            [UIImage imageNamed:@"campFire16.gif"],
                            [UIImage imageNamed:@"campFire17.gif"], nil];

// all frames will execute in 1.75 seconds
campFireView.animationDuration = 1.75;
// repeat the annimation forever
campFireView.animationRepeatCount = 0;
// start animating
[campFireView startAnimating];
// add the animation view to the main window 
[self.view addSubview:campFireView];

http://appsamuck.com/day2.html