如何在iOS应用程序中停止GIF?

时间:2017-06-30 06:32:42

标签: ios iphone swift

我在UIImageview中整合了一个 GIF 文件。它适用于我,但它会运行无限时间。我想在特定时间停止gif或 GIF 的周期?

1 个答案:

答案 0 :(得分:3)

您需要按照此处的说明配置您的imageview

https://github.com/bahlo/SwiftGif/wiki/Extended-use

let jeremyGif = UIImage.gifWithName("jeremy")

let imageView = UIImageView(...)
// Uncomment the next line to prevent stretching the image
// imageView.contentMode = .ScaleAspectFit
// Uncomment the next line to set a gray color.
// You can also set a default image which get's displayed 
// after the animation
// imageView.backgroundColor = UIColor.grayColor()

// Set the images from the UIImage
imageView.animationImages = jeremyGif?.images
// Set the duration of the UIImage
imageView.animationDuration = jeremyGif!.duration
// Set the repetitioncount
imageView.animationRepeatCount = 1
// Start the animation
imageView.startAnimating()