http://i60.tinypic.com/o7826u.png
http://i59.tinypic.com/2s139kl.png
图像解释了我想要的东西和我得到的东西。这是我的代码。
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)
}
答案 0 :(得分:1)
let lineView : UIView = UIView(frame: CGRect(0, 20, self.view.width, 2)
lineView.backgroundColor = UIColor.blackColor.colorWithAlphaComponent(0.2)