CAShapeLayer shadow

≯℡__Kan透↙ 提交于 2019-12-03 21:36:05

Very roughly:

    let arc1 = CAShapeLayer()
    arc1.lineWidth = 20.0
    arc1.path = UIBezierPath(ovalInRect: CGRectMake(10, 10, 80, 80)).CGPath
    arc1.strokeStart = 0
    arc1.strokeEnd = 0.5
    arc1.strokeColor = UIColor.grayColor().CGColor
    arc1.fillColor = UIColor.clearColor().CGColor
    layer.addSublayer(arc1)

    let cap = CAShapeLayer()
    cap.shadowColor = UIColor.blackColor().CGColor
    cap.shadowRadius = 8.0
    cap.shadowOpacity = 0.9
    cap.shadowOffset = CGSize(width: 0, height: 0)
    cap.path = UIBezierPath(ovalInRect: CGRectMake(0, 40, 20, 20)).CGPath
    cap.fillColor = UIColor.grayColor().CGColor
    layer.addSublayer(cap)

    let arc2 = CAShapeLayer()
    arc2.lineWidth = 20.0
    arc2.path = UIBezierPath(ovalInRect: CGRectMake(10, 10, 80, 80)).CGPath
    arc2.strokeStart = 0.5
    arc2.strokeEnd = 1.0
    arc2.strokeColor = UIColor.grayColor().CGColor
    arc2.fillColor = UIColor.clearColor().CGColor
    layer.addSublayer(arc2)

I think you need two arcs, and one circle for cap with shadow.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!