美文网首页
iOS 画虚线

iOS 画虚线

作者: 我将一直都在 | 来源:发表于2018-10-22 15:42 被阅读0次
    playground
    • 通过Quartz2D画虚线
        func drawDashLine(view: UIView) {
            let dashShapeLayer = CAShapeLayer()
            dashShapeLayer.strokeColor = UIColor.red.cgColor
            dashShapeLayer.lineWidth = 2
            let shapePath = CGMutablePath()
            dashShapeLayer.lineDashPattern = [10,5]
            shapePath.move(to: .init(x: 20, y: 230))
            shapePath.addLine(to: .init(x: 335, y: 230))
            dashShapeLayer.path = shapePath
            view.layer.addSublayer(dashShapeLayer)
        }
    

    相关文章

      网友评论

          本文标题:iOS 画虚线

          本文链接:https://www.haomeiwen.com/subject/ceegzftx.html