title: Shape a triangle with UIView backed by CAShapeLayer
body: <p>From the tutorial : <code>http://swiftiostutorials.com/tutorial-draw-nice-triangle-view-border-cashapelayer/</code>, i managed to create a triangle like :</p>
  
  <p><a href="https://i.stack.imgur.com/96Gm0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/96Gm0.png" alt="enter image description here"></a></p>
  
  <pre><code>class Triangle: UIView {
      override func drawRect(rect: CGRect) {
          let mask = CAShapeLayer()
          mask.frame = self.layer.bounds
  
          let width = self.layer.frame.size.width
          let height = self.layer.frame.size.height
  
          let path = CGPathCreateMutable()
  
          CGPathMoveToPoint(path, nil, 0, 0)
          CGPathAddLineToPoint(path, nil, width, 0)
          CGPathAddLineToPoint(path, nil, width, height)
          CGPathAddLineToPoint(path, nil, width/2, height)
          CGPathAddLineToPoint(path, nil, width, height)
  
  
          mask.path = path
          self.layer.mask = mask
      }
  }
  </code></pre>
  
  <p>But what i'm trying to achieve, is a triangle like :</p>
  
  <p><a href="https://i.stack.imgur.com/q2RFr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q2RFr.png" alt="enter image description here"></a></p>
  
  <p>How does one do this? </p>