我正在尝试用带有阴影的笔触颜色绘制一个空圆圈。
let bezierPath = UIBezierPath(ovalIn: CGRect(x: 80, y: 200, width: 100, height: 100))
let shapeLayer = CAShapeLayer()
shapeLayer.path = bezierPath.cgPath
shapeLayer.fillColor = UIColor.clear.cgColor
shapeLayer.strokeColor = UIColor.white.cgColor
shapeLayer.lineWidth = 3
shapeLayer.shadowPath = bezierPath.cgPath
shapeLayer.shadowColor = UIColor.black.cgColor
shapeLayer.shadowOffset = CGSize(width: 0, height: 0)
shapeLayer.shadowOpacity = 1
containerView.layer.addSublayer(shapeLayer)
但是阴影填满了整个圆圈。如何去掉它并保留外阴影?
Best Answer-推荐答案 strong>
只要省略设置shapeLayer.shadowPath ,你会得到这样的东西(图层的标准阴影,基本上就是图层的不透明部分):
关于ios - 带阴影的线圆,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/39349201/
|