我正在使用 AVAnimator 库来在我的 iOS 应用程序中使用电影动画。我的动画效果很好,但是我需要能够在动画结束后删除它,并且即使在前一个动画完成之前也允许相同的动画在其自身之上播放。
这是我用来制作动画的代码:
bassView = [AVAnimatorView aVAnimatorViewWithFrame:CGRectMake(322,460,375,224)];
AVAnimatorMedia *media = [AVAnimatorMedia aVAnimatorMedia];
AV7zAppResourceLoader *resLoader = [AV7zAppResourceLoader aV7zAppResourceLoader];
resLoader.archiveFilename = @"Archive.7z";
resLoader.movieFilename = @"bass_iPad.mvid";
resLoader.outPath = [AVFileUtil getTmpDirPath:@"bass_iPad.mvid"];
media.resourceLoader = resLoader;
AVMvidFrameDecoder *frameDecoder = [AVMvidFrameDecoder aVMvidFrameDecoder];
media.frameDecoder = frameDecoder;
media.animatorFrameDuration = AVAnimator10FPS; // this is a constant I made for the frame rate
[media prepareToAnimate];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(animatorDoneNotification:)
name:AVAnimatorDoneNotification
object:media];
[mainView addSubview:bassView];
[bassView attachMedia:media];
[media startAnimator];
- (void)animatorDoneNotification:(NSNotification*)notification {
NSLog(@"animation done");
AVAnimatorMedia *media = notification.object;
[media stopAnimator];
[bassView removeFromSuperview];
}