title: Rounded Curve Edge for UIView
body: <p>I am trying to add rounded edges via this extension , however I am getting proper rounded <code>UIView</code> in <code>iPhone X</code> but when I try to run this same code in <code>iPhone 6s</code> , its like not getting curved , tried to increase the <code>desiredCurve</code> still not able to see the curve.</p>
  
  <pre><code>extension UIView {
  
  
      /* Usage Example
       * bgView.addBottomRoundedEdge(desiredCurve: 1.5)
       */
      func addBottomRoundedEdge(desiredCurve: CGFloat?) {
          let offset: CGFloat = self.frame.width / desiredCurve!
          let bounds: CGRect = self.bounds
  
          let rectBounds: CGRect = CGRect(x: bounds.origin.x, y: bounds.origin.y, width: bounds.size.width, height: bounds.size.height / 2)
          let rectPath: UIBezierPath = UIBezierPath(rect: rectBounds)
          let ovalBounds: CGRect = CGRect(x: bounds.origin.x - offset / 2, y: bounds.origin.y, width: bounds.size.width + offset, height: bounds.size.height)
          let ovalPath: UIBezierPath = UIBezierPath(ovalIn: ovalBounds)
      rectPath.append(ovalPath)
  
          // Create the shape layer and set its path
          let maskLayer: CAShapeLayer = CAShapeLayer()
          maskLayer.frame = bounds
          maskLayer.path = rectPath.cgPath
  
          // Set the newly created shape layer as the mask for the view's layer
          self.layer.mask = maskLayer
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/SLLaT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SLLaT.jpg" alt="enter image description here"></a></p>