title: How to smooth the joint of lines in bezier path?
body: <p>I am trying to draw a cuboid shape using <code>UIBezierPath</code>. My drawing code is below:</p>
  
  <p>( (x, y) is origin of my <code>UIView</code> and (h, w) is its size) </p>
  
  <pre><code>UIBezierPath *bpath1 = [UIBezierPath bezierPath];
  [bpath1 moveToPoint:CGPointMake(x, y + h * 0.4)];
  [bpath1 addLineToPoint:CGPointMake(x, y + h)];
  [bpath1 addLineToPoint:CGPointMake(x + w - (w * 0.4), y + h)];
  [bpath1 addLineToPoint:CGPointMake(x + w - (w * 0.4), y + h * 0.4)];
  [bpath1 closePath];
  
  
  UIBezierPath *bpath2 = [UIBezierPath bezierPath];
  [bpath2 moveToPoint:CGPointMake(x + w * 0.4, y)];
  [bpath2 addLineToPoint:CGPointMake(x + w, y)];
  [bpath2 addLineToPoint:CGPointMake(x + w - (w * 0.4), y + h * 0.4];
  [bpath2 addLineToPoint:CGPointMake(x, y + h * 0.4];
  [bpath2 closePath];
  
  UIBezierPath *bpath3 = [UIBezierPath bezierPath];
  [bpath3 moveToPoint:CGPointMake(x + w, y)];
  [bpath3 addLineToPoint:CGPointMake(x + w, y + h - (h * 0.4))];
  [bpath3 addLineToPoint:CGPointMake(x + w - (w * 0.4), y + h)];
  [bpath3 addLineToPoint:CGPointMake(x + w - (w * 0.4), y + h * 0.4];
  [bpath3 closePath];
  </code></pre>
  
  <p>I created 3 paths because I wanted different alpha values for every path. I got the desired output which is below:</p>
  
  <p><img src="https://i.stack.imgur.com/COKJa.png" alt="General output"></p>
  
  <p>But to my surprise for very few values of <code>h</code>(height), I got the shape as below:</p>
  
  <p><img src="https://i.stack.imgur.com/m160G.png" alt="Strange shape for some &lt;code&gt;h&lt;/code&gt; values"></p>
  
  <p>Now, number of values for which this shape comes up is very few. Since rendering code is same every time, I don't understand this strange behaviour of bezier paths. Why bezier path is showing this behaviour and is there any way to smooth these joints?</p>