gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 10:53:52 25 4
gpt4 key购买 nike

我在 UIImageview 中集成了一个 GIF 文件。它对我来说很好用,但它会无限运行。我想在特定时间或 GIF 周期停止 gif?

最佳答案

您需要按照此处所述配置 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()

关于ios - 如何在 iOS 应用程序中停止 GIF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44840033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com