我一直試圖在Swift中動畫GIF,但它不起作用。我想我找到了一種方式,但有一個錯誤,請幫助。Swift中的動畫GIF動畫
下面的代碼:
@IBOutlet var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// (Here is the error it states "Cannot assign a value of type '[UIImage?]' to a value of type '[UIImage]?'")
imageView.animationImages = [
UIImage(named: "logo1.jpg"),
UIImage(named: "logo2.jpeg"),
UIImage(named: "logo3.png")
]
imageView.animationDuration = 3
imageView.startAnimating()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
// ...
}
這仍然不起作用,因爲問題是imageView.animationImages –
你能詳細說明這個原因嗎? –
我不知道爲什麼 –