title: How to draw a border around the content of a UIScrollView?
body: <p>I'm working on a document viewer. The document is displayed inside a <code>UIScrollView</code> so that it can be scrolled and zoomed. I need to draw a border around the document in order to separate it visually from the background of the <code>UIScrollView</code>. The border must not be zoomed together with the document -- it should maintain a constant thickness regardless of the zoom scale.</p>
  
  <p>My current setup consists of a <code>UIScrollView</code> with two <code>UIView</code> children -- one for the document, and one for the border. I've overriden <code>viewForZoomingInScrollView</code>: to return the document view. I've also overridden <code>layoutSubviews</code> to center the document view (in case it's smaller than the <code>UIScrollView</code>) and then resize and position the border view behind it so that it looks like a frame. This works OK when the user is scrolling and zooming manually. But when I use <code>zoomToRect:animated:</code> to zoom programatically, layoutSubviews is called before the animation starts and my border view gets resized immediately with the document view catching up a bit later.</p>
  
  <p><strong>Clarification: The border needs to be tightly fitting around the document view and not around the <code>UIScrollView</code> itself.</strong></p>