我想在我的视图上画一条细线,如我链接的图像所示

I want to draw a thin line on my view as shown in the images i linked

这些图片解释了我想要什么和我得到了什么。这是我的代码。

func drawLineFromPoint(start : CGPoint, 
    toPoint end:CGPoint, 
    ofColor lineColor: UIColor, 
    inView view:UIView) {
     let path = UIBezierPath() 
     path.moveToPoint(start) 
     path.addLineToPoint(end) 
     //design path in layer 
     let shapeLayer = CAShapeLayer() 
     shapeLayer.path = path.CGPath 
     shapeLayer.strokeColor = lineColor.CGColor 
     shapeLayer.lineWidth = 0.22 
     view.layer.addSublayer(shapeLayer) 
    }
let lineView : UIView = UIView(frame: CGRect(0, 20, self.view.width, 2)
lineView.backgroundColor = UIColor.blackColor.colorWithAlphaComponent(0.2)