title: Hide unused image in ScrollView (Swift)
body: <p>I need to hide the unused image. How to do it?
  In my code I have three images, but not always all of the images are being  used. How can I hide the third image? And later if I add the third image I need to unhide this image again without code changes.</p>
  
  <pre><code>import UIKit
  import Firebase
  import FirebaseDatabase
  import SDWebImage
  
  class ScrollViewController: UIViewController, UIScrollViewDelegate {
  
  @IBOutlet weak var scrollView: UIScrollView!
  
  var image = [String]()
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      loadImages()
  
  }
  func loadImages() {
  
      Database.database().reference().child("Студии2").observeSingleEvent(of: .value, with: { (snapshot) in
  
          let newImages = [String]()
  
          for child in snapshot.children {
              let snap = child as! DataSnapshot
              let imageSnap = snap.childSnapshot(forPath: "Photo")
              let dict = imageSnap.value as! [String: AnyObject]
              let url = dict["image"] as? String ?? ""
              let url2 = dict["image1"] as? String ?? ""
              let url3 = dict["image3"] as? String ?? ""
              self.image.append(url)
              self.image.append(url2)
              self.image.append(url3)
  
              for i in 0..&lt;self.image.count {
                  let imagesArray = UIImageView()
                  imagesArray.sd_setImage(with: URL(string: self.image[i]))
                  let xPos = self.view.frame.width * CGFloat(i)
                  imagesArray.frame = CGRect(x: xPos, y: 0, width: self.scrollView.frame.width, height: self.scrollView.frame.height)
  
  
                  self.scrollView.contentSize.width = self.scrollView.frame.width * CGFloat(i + 1)
                  self.scrollView.addSubview(imagesArray)
              }
          }
          self.image = newImages
      })
  }
  </code></pre>
  
  <p>Thanks for help.</p>