Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 带阴影的直线圆_Ios_Swift_Core Graphics_Shadow_Uibezierpath - Fatal编程技术网

Ios 带阴影的直线圆

Ios 带阴影的直线圆,ios,swift,core-graphics,shadow,uibezierpath,Ios,Swift,Core Graphics,Shadow,Uibezierpath,我用阴影创建了线圆,但当我试图更改阴影半径时,阴影没有显示出来 let path = UIBezierPath(ovalIn: rect) let shapeLayer = CAShapeLayer() shapeLayer.path = path.cgPath shapeLayer.fillColor = UIColor.clear.cgColor shapeLayer.strokeColor = UIColor.whi

我用阴影创建了线圆,但当我试图更改阴影半径时,阴影没有显示出来

let path = UIBezierPath(ovalIn: rect)
let shapeLayer              = CAShapeLayer()
shapeLayer.path             = path.cgPath
shapeLayer.fillColor        = UIColor.clear.cgColor
shapeLayer.strokeColor      = UIColor.white.cgColor
shapeLayer.lineWidth        = 1
shapeLayer.shadowOpacity    = 0.9
shapeLayer.shadowColor      = UIColor.white.cgColor
shapeLayer.shadowOffset     = .zero
shapeLayer.shadowRadius     = 10.0
//shapeLayer.shadowPath       = path.cgPath

layer.addSublayer(shapeLayer)

有人能帮我吗

如果要创建更强阴影的效果,可以使用已被笔划为大于投射阴影的路径的阴影路径。这可以通过以下方式实现:

这就是这种红色阴影的外观,无论有无任何模糊阴影半径:

您可以配置阴影模糊和笔划阴影路径的宽度,以实现所需的效果。以下是一些例子:


阴影在图片中,只是很微弱。是的,但我想要半径大于20.0的较大阴影。当我设置这个半径时,我没有看到阴影。你们能添加输出所需的图像吗?添加输出图像吗
shapeLayer.shadowPath = path.cgPath.copy(strokingWithWidth: width, lineCap: .round, lineJoin: .round, miterLimit: 0)