[ Swift ] How do I stop animating at last frame?

Hello every one?🙂

I use blow code. how do I stop animating at the Last image.

UIImage(named: "HangangBridge_05_img.png")! this image is the last frame of this animation.

actually I used 'NSTimer' like this issue. but I need more simple code.


    @IBAction func pressBtn_Bridge01(sender: AnyObject) {
  
        img_Bridge01.animationImages =
        [
            UIImage(named: "HangangBridge_01_img.png")!,
            UIImage(named: "HangangBridge_02_img.png")!,
            UIImage(named: "HangangBridge_03_img.png")!,
            UIImage(named: "HangangBridge_04_img.png")!,
            UIImage(named: "HangangBridge_05_img.png")!,
        ]
        img_Bridge01.animationDuration = 1
        img_Bridge01.animationRepeatCount = -1
        img_Bridge01.startAnimating()
Accepted Answer

you could try this:

@IBAction func pressBtn_Bridge01(sender: AnyObject)
{
     img_Bridge01.animationDuration = 1
     img_Bridge01.animationRepeatCount = 1
     img_bridge01.animationImages =
     [
          UIImage(named: "HangangBridge_01_img.png")!,
          UIImage(named: "HangangBridge_02_img.png")!,
          UIImage(named: "HangangBridge_03_img.png")!,
          UIImage(named: "HangangBridge_04_img.png")!,
          UIImage(named: "HangangBridge_05_img.png")!
     ]

     img_Bridge01.startAnimating()
}


This may work. I know .animationRepeatCount is how many times it runs through the animation. ".animationRepeatCount = 0" would make it run infinitely. ".animationRepeatCount = 1" would make it run once. I'm a newbie so I could be totally wrong, but hope this helps. 🙂

I solve this problem with Change Default image. Just added blow this.

lee_statue_img.image = UIImage(named: "HangangBridge_05_img.png")
[ Swift ] How do I stop animating at last frame?
 
 
Q