title: Scroll a UIViewController to the top just like it is done when clicking on the iOS Status Bar
body: <p>I would like to know if the method that Apple uses to scroll a <code>UIViewController</code> that contains a <code>UIScrollView</code> to the top when the user taps on the status bar is available to us. </p>
  
  <p>I tried to find it, but I had no success.</p>
  
  <p>I tried to reproduce it, but it did not work 100% when the <code>UIViewController</code> prefers to display large title (the large title is not expanded).</p>
  
  <p>How can we scroll a <code>UIViewController</code> to the top just like Apple does?</p>
  
  <hr>
  
  <p>Follows my trial:</p>
  
  <pre><code>extension UIViewController {
  
      private var firstScrollView: UIScrollView? {
          var scrollView: UIScrollView? = nil
  
          var viewsToCheck = [self.view]
          while !viewsToCheck.isEmpty &amp;&amp; scrollView == nil {
              let viewToCheck = viewsToCheck.remove(at: 0)!
  
              if let viewToCheckAsScrollView = viewToCheck as? UIScrollView {
                  scrollView = viewToCheckAsScrollView
              } else {
                  viewsToCheck.append(contentsOf: viewToCheck.subviews)
              }
          }
  
          return scrollView
      }
  
      func scrollToTheTop(animated: Bool) {
          if let firstScrollView = firstScrollView {
              firstScrollView.scrollRectToVisible(CGRect(x: 0, y: 0, width: 1, height: 1), animated: true)
          }
      }
  }
  </code></pre>