title: How to make a dashed or dotted line in Swift 4
body: <p>I've been trying to do this in a playground like this:</p>
  
  <pre><code>import UIKit
  import XCPlayground
  
  let path = UIBezierPath()
  path.move(to: CGPoint(x:10,y:10))
  path.addLine(to: CGPoint(x:290,y:10))
  path.lineWidth = 2
  
  let dashPattern : [CGFloat] = [0, 16] 
  path.setLineDash(dashPattern, count: 2, phase: 0)
  path.lineCapStyle = CGLineCap.round
  path.lineCapStyle = .butt
  UIGraphicsBeginImageContextWithOptions(CGSize(width:300, height:20), false, 2)
  path.stroke()
  
  XCPlaygroundPage.currentPage.captureValue(value: UIGraphicsGetImageFromCurrentImageContext(), withIdentifier: "image")
  UIGraphicsEndImageContext()
  </code></pre>
  
  <p>But the result is:</p>
  
  <p><a href="https://i.stack.imgur.com/JLcrK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JLcrK.png" alt="enter image description here"></a></p>