Freeze last frame of animation new code?

穿精又带淫゛_ 提交于 2019-12-05 22:25:13

I spend 40 my minutes to resolve your problem, and it was just so simple:

There are two way you can achieve what you want:

  1. Set the image you want on your screen as default image.
  2. or just do this,

    //make your last line to first line.  
    animation.image = [UIImage imageNamed:@"watermelondrop16.png"];
    animation.animationImages = [NSArray arrayWithObjects:
                         [UIImage imageNamed:@"watermelondrop2.png"],
                         [UIImage imageNamed:@"watermelondrop4.png"],
                         [UIImage imageNamed:@"watermelondrop6.png"],
                         [UIImage imageNamed:@"watermelondrop8.png"],
                         [UIImage imageNamed:@"watermelondrop10.png"],
                         [UIImage imageNamed:@"watermelondrop12.png"],
                         [UIImage imageNamed:@"watermelondrop14.png"],
                         [UIImage imageNamed:@"watermelondrop15.png"], nil];
    
    animation.animationDuration = .8;
    animation.animationRepeatCount = 1;
    [animation startAnimating];
    [self playwatermelondropsound];
    [self.view addSubview:animation];
    

And guess what it'll start working, as I have tested it. :)

[self cleanStance];
NSArray *imageArray = [[NSArray alloc] initWithObjects:
                       [UIImage imageNamed:@"jump1.png"],
                       [UIImage imageNamed:@"jump2.png"],
                       nil];    
self.player.animationImages = imageArray;
self.player.animationDuration = 0.3;
//self.player.contentMode = UIViewContentModeBottomLeft;
[self.view addSubview:self.player];
[self.player startAnimating];


- (void)cleanStance {
[self.player setImage:nil];
self.player.animationImages = nil;

}

This is the example to show the image jumping i thick this may help u

Your code looks fine to me, except when I do it, I usually set the .image property of the UIImageView BEFORE I tell the UIImageView to start animating. Also, add [UIImage imageNamed:@"watermelondrop16.png"] to the end of your .animationImages array. Maybe that will fix your problem. Hope that Helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!