我一直试图在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 –
你能详细说明这个原因吗? –
我不知道为什么 –