title: UILabel textRectForBounds has no effect when trying to create margin
body: <p>I'm trying to indent the text in a UILabel to leave some margin around the text showing the background colour. Following the suggestion <a href="https://stackoverflow.com/questions/3476646/uilabel-text-margin">here</a> I've overriden <code>textRectForBounds:limitedToNumberOfLines:</code> like so:</p>
  
  <pre><code>- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines
  {
      CGRect intermediate = CGRectMake(bounds.origin.x+MARGIN,bounds.origin.y+MARGIN,bounds.size.width-2*MARGIN,bounds.size.height-2*MARGIN);
      return [super textRectForBounds:intermediate limitedToNumberOfLines:numberOfLines];
  }
  </code></pre>
  
  <p>But no matter what I do, the text ends up tight against the left border of the rectangle. It seems as though the drawing is ignoring the origin part of the returned CGRect (although it seems to be respecting the width part, as if I reduce to width of intermediate to eg <code>bounds.size.width-200</code> the rect that textRectForBounds returns is suitably narrow and the text is drawn in a long skinny column).</p>
  
  <p>So: what else I need to do to the <code>UILabel</code> to make the drawing respect the <code>textForRectBounds</code>-returned-rect's origin.x and origin.y? I'd rather not override <code>UILabel</code>'s <code>drawTextInRect</code> if I can help it.</p>
  
  <p><strong>Update</strong>: This was a long time ago and I can't remember exactly why the other question didn't work for me. I believe it was because I was trying to have a <code>UILabel</code> with multiple lines, and the solution <a href="https://stackoverflow.com/questions/3476646/uilabel-text-margin">here</a> didn't work in that case.</p>