Source: BorgGreen
func drawLine(xorig: CGFloat, yorig: Int, xlen: Int, ylen: Int, color: CGColor) {
let doYourPath = UIBezierPath(rect: CGRect(x: Int(xorig), y: yorig, width: xlen, height: ylen))
let layer = CAShapeLayer()
layer.path = doYourPath.cgPath
layer.strokeColor = color
layer.fillColor = color
self.view.layer.addSublayer(layer)
}