title: iPad/iPhone - NSString drawInRect not word wrapping
body: <p>I'm using the following to render some text in a <code>UIView</code>. </p>
  
  <pre><code>- (void) drawRect:(CGRect)rect
  {
  
      NSString* text = @"asdf asdf asdf asdf asdf asdf asdf";
  
      CGContextRef context = UIGraphicsGetCurrentContext();
  
      CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
  
      CGContextFillRect(context, rect);
  
      CGContextSetTextDrawingMode(context, kCGTextFillStrokeClip);
  
      CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
  
      CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]);
  
      CGContextSetShouldSmoothFonts(context, YES);
  
      UIFont* font = [UIFont fontWithName:@"ArialRoundedMTBold" size:20.0f]; 
  
      CGSize textMaxSize = CGSizeMake(rect.size.width - 20.0f, rect.size.height);
  
      CGSize textSize = [text sizeWithFont:font constrainedToSize:textMaxSize lineBreakMode:UILineBreakModeWordWrap];
  
      CGRect textRect = CGRectMake(10.0f, 10.0f, textSize.width, textSize.height);
  
      [text drawInRect:textRect withFont:font];
  
      [text drawInRect:textRect withFont:font lineBreakMode:UILineBreakModeWordWrap]; 
  
      [text drawInRect:textRect withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
  }
  </code></pre>
  
  <p>None of the <code>[text drawInRect]</code>'s wrap the text like I expect. <code>TextSize</code> is computed properly but the draw is just rendering a single line. </p>
  
  <p>Update:</p>
  
  <p>Solved. </p>
  
  <p>Settings <code>CGContextSetTextDrawingMode(context, kCGTextFillStrokeClip);</code> will cause the text to clip regardless of <code>UILineBreak</code> mode selected. Setting <code>CGContextSetTextDrawingMode(context, kCGTextFillStroke);</code> solved this issue. </p>