Search code examples
iosswiftcashapelayer

CAShapeLayer draws different line width for one path, Swift


i have a problem while drawing curve:

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)

and i have unexpectable result:

curve

curve is bold than the line, have somebody idea why it happened and how it fixing?


Solution

  • sorry, its my mistake after review many lines of code i find active "Clip to bounds" property of one of my parent view