title: How do I prevent a text stroke from cutting off at the edge of a UILabel?
body: <p>I'm adding a fairly wide stroke of a few pixels to text in a <code>UILabel</code>, and depending on the line spacing, if the very edges of the text touch the very edges of the label, the sides of the stroke can be cut off, if they go outside of the bounds of the label. <strong>How can I prevent this?</strong> Here's the code I'm using to apply the stroke (currently of 5px):</p>
  
  <pre><code>- (void) drawTextInRect: (CGRect) rect
  {
      UIColor *textColor = self.textColor;
  
      CGContextRef c = UIGraphicsGetCurrentContext();
      CGContextSetLineWidth(c, 5);
      CGContextSetLineJoin(c, kCGLineJoinRound);
      CGContextSetTextDrawingMode(c, kCGTextStroke);
      self.textColor = [UIColor colorWithRed: 0.165 green: 0.635 blue: 0.843 alpha: 1.0];
      [super drawTextInRect: rect];
  }
  </code></pre>
  
  <p>Here's an example of the clipping at the side of the label, I think what needs to happen is one of the following:</p>
  
  <ul>
  <li>That when the text splits onto multiple lines, some space is given inside the label's frame for the stroke to occupy.</li>
  <li>Or, that the stroke is allowed to overflow the outer bounds of the label.</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/avYJ4.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/Nwioy.png" alt="enter image description here"></p>