CAShapeLayer为一条路径绘制不同的线宽,Swift

时间:2019-03-01 15:46:24

标签: ios swift cashapelayer

我在绘制曲线时遇到问题:

strokePath = UIBezierPath()
strokePath.move(to: CGPoint(x:curveWidth / 2.0 -  headerWidth, y: headerHeight))
strokePath.addLine(to: CGPoint(x: 0, y: headerHeight))
strokePath.addCurve(to: CGPoint(x: curveRadius, y: headerHeight - curveRadius),
                    controlPoint1: CGPoint(x: degree, y: headerHeight),
                    controlPoint2: CGPoint(x: curveRadius, y: headerHeight - curveRadius))
strokePath.addLine(to: CGPoint(x: curveWidth - curveRadius, y: curveRadius))
strokePath.addCurve(to: CGPoint(x: curveWidth, y: 0),
                    controlPoint1: CGPoint(x: curveWidth - curveRadius + curveRadius * 0.25, y: 0),
                    controlPoint2: CGPoint(x: curveWidth, y: 0))
strokePath.addLine(to: CGPoint(x: self.frame.size.width, y: 0.0))

strokeLayer.path = strokePath.cgPath
strokeLayer.strokeColor = uiConfig.color.misc.tabGrayBorder.cgColor
strokeLayer.fillColor = UIColor.clear.cgColor
strokeLayer.lineWidth = 0.5
self.layer.addSublayer(strokeLayer)

而我的结果出乎意料:

curve

曲线比线条大胆,有人知道它为什么发生以及如何修复?

1 个答案:

答案 0 :(得分:0)

对不起,在检查了多行代码后,我发现自己的错误是我的错,我发现我的父视图之一具有有效的“限界”属性

相关问题