在Swift中随机播放图像

时间:2014-12-24 21:38:37

标签: arrays swift shuffle

我如何在Swift中改组这些图像?我在网上找到了各种实现,但在处理这个图像数组时似乎都没有。任何信息将不胜感激。谢谢。

 @IBOutlet weak var imageView: UIImageView!

let images = [
    UIImage(named: "image1.png")!,
    UIImage(named: "image2.png")!,
    UIImage(named: "image3.png")!,
    UIImage(named: "image4.png")!]

var index = 0
let animationDuration: NSTimeInterval = 1.5
let switchingInterval: NSTimeInterval = 3

override func viewDidLoad() {
    super.viewDidLoad()


    imageView.image = images[index++] // going through the images array
    animateImageView()

0 个答案:

没有答案