let path = UIBezierPath(roundedRect: CGRect(x: 10, y: item.20, width: item.355, height: 94), cornerRadius: 31).cgPath ctx.addPath(path) ctx.setStrokeColor(UIColor(.red).cgColor) ctx.setLineWidth(1) ctx.drawPath(using: .stroke)
代码中的 cornerRadius 31 是极限,再大的话圆角也不会变。如果是正方形圆角值可以跟边长一致,这种长方形的最大圆角值是怎么算出来的?
![]() | 1 ysc3839 2020-10-26 19:18:36 +08:00 via Android 不讨论具体平台,只讨论画圆角矩形的算法的话,应该是用九宫格画法吧?四个角由矩形换成四分之一圆,这样的话圆角最大半径应该是短边长度的一半吧? |