2017-06-20 40 views

回答

1

對於實施例中,我使用這個庫視圖GIF圖像:https://github.com/kirualex/SwiftyGif

var imagesName:[String] = ["image1.gif","image2.gif"] 
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { 
     guard touches.count == 1 else { 
      return 
     } 
     let index = Int(arc4random_uniform(1)) 

     if let touch = touches.first { 
      self.gifImageView.image = UIImage(gifName: self.imagesName[index]) 
     } 
    }