title: I cannot understand the behavior of scrollRectToVisible:animated: with scrollView.contentInset set
body: <p>When <code>scrollView.contentInset = UIEdgeInsetsZero</code>, everything is just OK, so the problem I run into arises when <code>scrollView.contentInset</code> is set manually.</p>
  
  <p>In order to describe the problem, I'll make a simple demo.</p>
  
  <p>Drag a scroll view (also make a reference to it, and set its background color to be different from white, say <strong>red</strong>) onto the scene, then drag a view onto the scroll view (don't forget to set its background color, say <strong>green</strong>), they are the same size and completely overlap. The document outline is as below:</p>
  
  <p><a href="https://i.stack.imgur.com/C0qEB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C0qEB.png" alt="enter image description here"></a></p>
  
  <p>Then some code:</p>
  
  <pre><code>let top: CGFloat = 100
  let bottom: CGFloat = 50
  
  override func viewDidLoad() {
      super.viewDidLoad()
      scrollView.contentSize = CGSizeMake(scrollView.bounds.width, 1000)
      scrollView.contentInset = UIEdgeInsetsMake(top, 0, bottom, 0)
  }
  
  override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated)
      scrollView.scrollRectToVisible(CGRectMake(0, 0, scrollView.bounds.width, scrollView.bounds.height - bottom), animated: false) // this line will be change
  }
  </code></pre>
  
  <p>The effect is as below, just as I expect:</p>
  
  <p><a href="https://i.stack.imgur.com/7WyTZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7WyTZ.png" alt="enter image description here"></a></p>
  
  <p>But if I change the last line of code to be</p>
  
  <pre><code>scrollView.scrollRectToVisible(CGRectMake(0, 0, scrollView.bounds.width, scrollView.bounds.height - (bottom + 1)), animated: false)
  </code></pre>
  
  <p>The effect is like this:</p>
  
  <p><a href="https://i.stack.imgur.com/CoZIn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CoZIn.png" alt="enter image description here"></a></p>
  
  <p>I've changed only one point! What I expect is </p>
  
  <p><a href="https://i.stack.imgur.com/qiixB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qiixB.png" alt="enter image description here"></a></p>
  
  <p>How to explain this?</p>