title: Parallax effect with UIScrollView subviews
body: <p>I'm trying to create a Parallax effect on a UIView inside a UIScrollView.
  The effect seems to work, but not so well. </p>
  
  <ol>
  <li>First i add two UIView sub-views to a UIScrollView and set the UIScrollViews contentSize.</li>
  <li>The Views sum up and create a contentSize of {320, 1000}.</li>
  <li><p>Then I implemented the following in scrollViewDidScroll:</p>
  
  <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView
  {
      CGFloat offsetY = scrollView.contentOffset.y;
  
      CGFloat percentage = offsetY / scrollView.contentSize.height;
  
      NSLog(@"percent = %f", percentage);
  
      if (offsetY &lt; 0) {
  
          firstView.center = CGPointMake(firstView.center.x, firstView.center.y - percentage * 10);
  
      } else if (offsetY &gt; 0){
  
          firstView.center = CGPointMake(firstView.center.x, firstView.center.y + percentage * 10);
  
      }
  }
  </code></pre></li>
  </ol>
  
  <p>These lines of code do create a parallax effect, but as the scrolling continues, the view does not return to it's original position if i scroll to the original starting position.</p>
  
  <p>I have tried manipulating the views layers and frame, all with the same results.</p>
  
  <p>Any Help will be much appreciated. </p>