2017-06-30 24 views
-1

我整合了一個GIF文件在UIImageview。它對我來說工作正常,但它會運行無限的時間。我想在特定時間停止gif或循環GIF如何在iOS應用程序中停止GIF?

+0

你使用庫GIF? – KKRocks

+0

@KKRocks,是的,我用SwiftGif第三方庫 – Hemanshu

+0

添加你的代碼,你如何設置GIF到UIImageView? – Venkat

回答

2

您需要配置的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() 
+0

謝謝你對我有用 – Hemanshu