小编Val*_*riy的帖子

我怎样才能圆角UIBezierPath?

我有一个用于相机的图层,您可以在图 1 中看到,我需要像图 2 那样的圆角。我如何将其圆化。

图片1:在此输入图像描述图片2:在此输入图像描述

    if cornerRadius > cornerLength { cornerRadius = cornerLength }
    if cornerLength > maskContainer.width / 2 { cornerLength = maskContainer.width / 2 }

    let upperLeftPoint = CGPoint(x: maskContainer.minX, y: maskContainer.minY)

    let upperLeftCorner = UIBezierPath()
    upperLeftCorner.move(to: upperLeftPoint.offsetBy(dx: 0, dy: cornerLength))
    upperLeftCorner.addArc(withCenter: upperLeftPoint.offsetBy(dx: cornerRadius, dy: cornerRadius),
                           radius: cornerRadius, startAngle: .pi, endAngle: 3 * .pi / 2, clockwise: true)
    upperLeftCorner.addLine(to: upperLeftPoint.offsetBy(dx: cornerLength, dy: 0))

    let combinedPath = CGMutablePath()
    combinedPath.addPath(upperLeftCorner.cgPath)
Run Code Online (Sandbox Code Playgroud)

ios uibezierpath swift

0
推荐指数
1
解决办法
727
查看次数

标签 统计

ios ×1

swift ×1

uibezierpath ×1