Drawing an animatable laser beam with CALayer


I'm trying to draw a light beam using CAShapeLayer but not able to correctly implement it. Have used the shadow properties but it isn't totally reflecting the way the beam should glow.

pathLayer.path = UIBezierPath.getSpiralPath().cgPath
pathLayer.fillColor = UIColor.clear.cgColor
pathLayer.strokeColor = UIColor.white.cgColor
pathLayer.lineWidth = 3
pathLayer.shadowColor = glowColor.cgColor
pathLayer.shadowOffset = CGSize(width: 0, height: 0)
pathLayer.shadowRadius = 12
pathLayer.shadowOpacity = 1
pathLayer.lineCap = kCALineCapRound
pathLayer.lineJoin = kCALineJoinRound

The actual result isn't very sharp and have not much glow, I have tried using blend modes but they are of no use (or I failed to understand how it should be used).

Laser Beam


Answers: