这些图像解释了我想要什么和我得到什么。这是我的代码。
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)
关于swift - 我想在我的 View 上画一条细线,如我链接的图像所示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33259678/