我看到了很多以下格式的例子
extension Protocolname where Self: UIViewController
Run Code Online (Sandbox Code Playgroud)
什么是where Self协议扩展.我找不到关于此的文档.
我想使用UIBazierpath渐变色填充圆的一半边框。
最初我尝试使用完整的圆圈但它不起作用,渐变总是填充圆圈而不是边框。有没有办法做到这一点?
这是我到目前为止所拥有的:
let path = UIBezierPath(roundedRect: rect, cornerRadius: rect.width/2)
let shape = CAShapeLayer()
shape.path = path.cgPath
shape.lineWidth = 2.0
shape.strokeColor = UIColor.black.cgColor
self.layer.addSublayer(shape)
let gradient = CAGradientLayer()
gradient.frame = path.bounds
gradient.colors = [UIColor.magenta.cgColor, UIColor.cyan.cgColor]
let shapeMask = CAShapeLayer()
shapeMask.path = path.cgPath
gradient.mask = shapeMask
shapeMask.lineWidth = 2
self.layer.addSublayer(gradient)
Run Code Online (Sandbox Code Playgroud)