Fix corner radius

This commit is contained in:
Ali 2022-11-09 17:43:54 +04:00
parent e64016553e
commit f03c3b6cad

View File

@ -77,6 +77,7 @@ private func generateRectsImage(color: UIColor, rects: [CGRect], inset: CGFloat,
context.setBlendMode(.copy)
if useModernPathCalculation {
var rects = rects.map { $0.insetBy(dx: -inset, dy: -inset).offsetBy(dx: -topLeft.x, dy: -topLeft.y) }
if rects.count > 1 {
let minRadius: CGFloat = 2.0
@ -121,7 +122,6 @@ private func generateRectsImage(color: UIColor, rects: [CGRect], inset: CGFloat,
}
}
if useModernPathCalculation {
context.move(to: CGPoint(x: rects[0].midX, y: rects[0].minY))
context.addLine(to: CGPoint(x: rects[0].maxX - outerRadius, y: rects[0].minY))
context.addArc(tangent1End: rects[0].topRight, tangent2End: CGPoint(x: rects[0].maxX, y: rects[0].minY + outerRadius), radius: outerRadius)
@ -181,13 +181,13 @@ private func generateRectsImage(color: UIColor, rects: [CGRect], inset: CGFloat,
context.fillPath()
return
}
} else {
let path = UIBezierPath(roundedRect: rects[0], cornerRadius: outerRadius).cgPath
context.addPath(path)
context.fillPath()
return
}
}
for i in 0 ..< rects.count {
let rect = rects[i].insetBy(dx: -inset, dy: -inset)