title: Smooth UIBezierPath
body: <p>I created in a playground a uibezierpath added manually values and it works fine. The results is : 
  <a href="https://i.stack.imgur.com/kBIaJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kBIaJ.png" alt="enter image description here"></a></p>
  
  <p>Now my goal is to smooth the curve and remove these "sharp" corners. I'm thinking on a interpolation function but not sure. Below my actual code : </p>
  
  <pre><code>//: Playground - noun: a place where people can play
  
  import Foundation
  import UIKit
  import CoreGraphics
  import QuartzCore
  
  class DemoView: UIView {
  
  
      override func draw(_ rect: CGRect) {
          let origin = CGPoint(x: frame.size.width / 2, y: frame.size.height / 2)
          let radius = frame.size.width / 2
  
  //        self.createCircle(origin: origin, radius: radius)
          self.addLinesInCircle(origin: origin, radius: radius)
      }
  
      func createCircle(origin: CGPoint, radius: CGFloat) {
          let path = UIBezierPath()
          path.addArc(withCenter: origin, radius: radius, startAngle: 0, endAngle: CGFloat(2 * Double.pi), clockwise: true)
          path.close()
          UIColor.clear.setFill()
          path.fill()
      }
  
      func addLinesInCircle(origin: CGPoint, radius: CGFloat) {
          let bezier = UIBezierPath()
  
          let incrementAngle: CGFloat = CGFloat.pi / 24
          let ratios: [CGFloat] = [3/6, 5/6, 3/6, 1/6, 5/6, 2/6, 4/6, 2/6, 4/6, 4/6, 4/6, 4/6,
                                   3/6, 5/6, 3/6, 1/6, 5/6, 2/6, 4/6, 2/6, 4/6, 4/6, 4/6, 4/6,
                                   3/6, 5/6, 3/6, 1/6, 5/6, 2/6, 4/6, 2/6, 4/6, 4/6, 4/6, 4/6,
                                   3/6, 5/6, 3/6, 1/6, 5/6, 2/6, 4/6, 2/6, 4/6, 4/6, 4/6, 4/6]
  
          for (index, ratio) in ratios.enumerated() {
              let point = CGPoint(x: origin.x + cos(CGFloat(index) * incrementAngle) * radius * ratio,
                                  y: origin.y + sin(CGFloat(index) * incrementAngle) * radius * ratio)
              if index == 0 {
                  bezier.move(to: point)
              } else {
                  bezier.addLine(to: point)
              }
          }
  
          bezier.close()
  
  
          let gradient = CGGradient(colorsSpace: nil, colors: [UIColor.red.cgColor,UIColor.blue.cgColor,UIColor.yellow.cgColor ,UIColor.black.cgColor] as CFArray, locations: nil)!
  
          let ctx = UIGraphicsGetCurrentContext()!
               ctx.saveGState()
  
          // Clip to the path
          bezier.addClip()
          // Draw the gradient in the clipped region
          ctx.drawLinearGradient(gradient, start: CGPoint(x: 0, y: 0), end: CGPoint(x: 0, y: frame.height), options: [])
  
          ctx.restoreGState()
  
      }
  
  }
  
  let demoView = DemoView(frame: CGRect(x: 0, y: 0, width: 1000, height: 1000))
  </code></pre>
  
  <p>If anyone has an idea or just keys words in order to look in the right direction? Thanks in advance for your help. I hope my explanations are enough...</p>