title: Using UIButtons to move left, right, up and down in a zoomed in UIImageView
body: <p>I searched many resources with no result so far.</p>
  
  <p>I'm able to successfully zoom in/out and move left, right, up and down by swiping in a UIImageView under it a ScrollView.</p>
  
  <p>How to achieve the same by using buttons? I could do the zoom in and zoom out using this code: </p>
  
  <pre><code>@IBAction func zoomIn(_ sender: UIBarButtonItem) {
      imageScrollView.maximumZoomScale = 6.0
      if imageScrollView.zoomScale &lt; imageScrollView.maximumZoomScale {
          imageScrollView.zoomScale = imageScrollView.zoomScale + 0.1
      }
  }
  
  @IBAction func zoomOut(_ sender: UIBarButtonItem) {
      imageScrollView.minimumZoomScale = 1
      if imageScrollView.zoomScale &gt; imageScrollView.minimumZoomScale {
          imageScrollView.zoomScale = imageScrollView.zoomScale - 0.1
      }
  }
  </code></pre>
  
  <p>And this is the code I'm using:</p>
  
  <pre><code>@IBOutlet weak var imageScrollView: UIScrollView!
  @IBOutlet weak var imageView: UIImageView!
  
      override func viewDidLoad() {
      super.viewDidLoad()
  
      imageScrollView.contentSize = self.imageView.frame.size
      imageScrollView.delegate = self
    }
  
  
  override func viewWillLayoutSubviews() {
      super.viewWillLayoutSubviews()
      updateMinZoomScaleForSize(view.bounds.size)
  }
  
  // MARK: - Calculation of zoom scale for imageScrollView
  fileprivate func updateMinZoomScaleForSize(_ size: CGSize) {
      let widthScale = size.width / imageView.bounds.width
      let heightScale = size.height / imageView.bounds.height
      let minScale = min(widthScale, heightScale)
  
      imageScrollView.minimumZoomScale = minScale
      imageScrollView.zoomScale = minScale
  }
  </code></pre>
  
  <p>I need to add 4 more buttons in a shape of arrows to move left, right, up and down. The purpose of doing all this is because I want to draw and zoom in a UIImageView at the same time and that's causing conflicts. </p>