ios – 如何为UIBezierPath提供cornerRadius

我使用以下代码创建了一个矩形,现在我需要舍入这个矩形的角.但是我找不到一个名为layer.cornerRadius的属性,有人可以帮帮我吗?
class ovalLayer: CAShapeLayer {

    let animationDuration: CFTimeInterval = 0.3

    override init() {
        super.init()
        fillColor = Colors.green.CGColor
        path = ovalPathSmall.CGPath
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
var ovalPathStart: UIBezierPath {
        let path = UIBezierPath(ovalInRect: CGRect(x: 0.0,y: 0.0,width: 100.0,height: 100.0))

        return path
    }
}

解决方法

您可以使用以下方法制作所有角落视图…
UIBezierPath(roundedRect: anyView.bounds,cornerRadius: CGSize(width: 10.0,height: 10.0))

如果你想要特定的角落在下面的方法使用.

UIBezierPath(roundedRect: anyView.bounds,byRoundingCorners: .BottomLeft | .Bottomright,height: 10.0))

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...