尝试在swift 2.0中动画系列图像,但是按照像https://www.youtube.com/watch?v=PSny6un3VUw这样的视频教程,这个人使用的方法不再相关,swift 2.0不再允许以这种方式设置数组。这个人使用的基本代码如下:
class ViewController: UIViewController: {
@IBOutlet var myImageView: UIImageView
@IBOutlet var animationBtn: UIButton
var imageList = UIImage[]() // no longer valid?
@IBAction func animationBtnClicked(sender: AnyObject) {
startAnimation
}
override func viewDidLoad() {
for i in 1...13
{
let imageName = "\(1)"
imageList += UIImage(named: imageName) //line no longer works
}
}
func startAnimation() -> Void
{
myImageView.animationImages = imageList
myImageView.startAnimation()
}
任何人都知道在swift 2.0中更好的方式来制作图像动画,或者总体而言如何做到这一点?
答案 0 :(得分:0)
我希望我会帮助你
@IBOutlet var myImageView: UIImageView!
@IBOutlet var animationBtn: UIButton!
var imageList = [UIImage]()
imageList.append(UIImage(named: imageName))
要么
imageList += [UIImage(named: imageName)]