title: iOS: Layer shadow path is not correct
body: <p>I have <code>UIView</code> in my design and I need to allow user to change the corner radius. I have designed the testier using <code>@IBDesignable</code> and <code>@IBInspectable</code>.</p>
  
  <p>I am getting the expected shape(<code>cornerRadius</code> curve) upto the 33% of <code>cornerRadius</code></p>
  
  <p><code>e.g bounds.size.width = 100</code>,
   I am getting correct shadow shape if corner radius is upto 33. </p>
  
  <p>If <code>cornerRadius</code> is more than 33 then shadow shape becomes circle irrespective of original shape <code>cornerRadius</code>.</p>
  
  <p>Any suggestion?</p>
  
  <p>Please refer the code and design screenshot below,</p>
  
  <p>Code:</p>
  
  <pre><code>@IBDesignable class DrawingView: UIView {
  
      @IBInspectable var cornerRadius: CGFloat = 0.0
  
      @IBInspectable var borderWidth: CGFloat = 0.0
      @IBInspectable var borderColor: UIColor = .clear
  
      @IBInspectable var shadowRadius: CGFloat = 0.0
      @IBInspectable var shadowOffset: CGSize = .zero
      @IBInspectable var shadowColor: UIColor = .clear
  
      override func draw(_ rect: CGRect) {
          // Drawing code
          self.layer.cornerRadius = cornerRadius
          self.clipsToBounds = true
          self.layer.borderWidth = borderWidth
          self.layer.borderColor = borderColor.cgColor
  
          let path = UIBezierPath(roundedRect: self.bounds, cornerRadius: self.cornerRadius)
          self.layer.shadowPath = path.cgPath
          self.layer.shadowRadius = shadowRadius
          self.layer.shadowOffset = shadowOffset
          self.layer.shadowColor = shadowColor.cgColor
          self.layer.masksToBounds = false
          self.layer.shadowOpacity = 1.0
      }
  }
  </code></pre>
  
  <p><strong>Screenshots</strong>:</p>
  
  <p>Corner Radius = 20%</p>
  
  <p><a href="https://i.stack.imgur.com/nUVNf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nUVNf.png" alt="corenerRadius 20"></a></p>
  
  <p>Corner Radius >= 33%</p>
  
  <p><a href="https://i.stack.imgur.com/Iq579.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Iq579.png" alt="cornerRadius &gt;= 33"></a></p>