我在UIImageview
中整合了一个 GIF 文件。它适用于我,但它会运行无限时间。我想在特定时间停止gif或 GIF 的周期?
答案 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()