title: CAShapeLayer line's rounded corners
body: <p>I want to draw diagonal line with rounded corners in view.
  My code:</p>
  
  <pre><code>class DiagonalView: UIView {
  
  // MARK: - Public Properties
  
  @IBInspectable var fillColor: UIColor = UIColor.white {
      didSet {
          self.diagonalLayer.strokeColor = fillColor.cgColor
          self.redraw()
      }
  }
  
  @IBInspectable var lineWidth: CGFloat = 1 {
      didSet {
          self.diagonalLayer.lineWidth = lineWidth
          self.redraw()
      }
  }
  
  // MARK: - Private Properties
  
  private var diagonalLayer: CAShapeLayer = {
      let layer = CAShapeLayer()
      layer.fillColor = UIColor.clear.cgColor
      layer.strokeColor = UIColor.white.cgColor
      layer.lineCap = kCALineCapRound
      layer.lineWidth = 1
      return layer
  }()
  
  // MARK: - Constructors
  
  override func awakeFromNib() {
      super.awakeFromNib()
      self.layer.addSublayer(self.diagonalLayer)
      self.setupPath()
  }
  
  override func layoutSubviews() {
      super.layoutSubviews()
      self.setupPath()
  }
  
  // MARK: - Private methods
  
  private func redraw() {
      self.setNeedsDisplay()
  }
  
  private func setupPath() {
      let startPoint = CGPoint(x: self.frame.width, y: 0)
      let endPoint = CGPoint(x: 0, y: self.frame.height)
      let path = UIBezierPath()
      path.move(to: startPoint)
      path.addLine(to: endPoint)
      path.close()
      self.diagonalLayer.path = path.cgPath
  }
  
  }
  </code></pre>
  
  <p>Line position is right. But corners are not rounded.
  Result:</p>
  
  <p><a href="https://i.stack.imgur.com/qGPwz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qGPwz.png" alt="enter image description here"></a></p>
  
  <p>The code looks good but think I mess something... Any suggestions?</p>