title: How to fill a bezier path with gradient color
body: <p>I have a <code>UIBezierPath</code> inside my custom <code>UIView draw(_ rect: CGRect)</code> function. I would like to fill the path with a gradient color. Please can anybody guide me how can I do that.</p>
  
  <p>I need to fill the clip with a gradient color and then stroke the path with black color.</p>
  
  <p>There are some posts in SO which does not solve the problem. For example <a href="https://stackoverflow.com/questions/27931076/swift-gradient-along-a-bezier-path-using-calayers">Swift: Gradient along a bezier path (using CALayers)</a> this post guides how to draw on a layer in <code>UIView</code> but not in a <code>UIBezierPath</code>.</p>
  
  <p><strong>NB: I am working on Swift-3</strong></p>