I want to add a glow effect to a path, like the blue glow around (OS X) interface elements when they have focus.
I used a CAShapeLayer with a (rectangular) path:
self.borderLayer = [CAShapeLayer layer];
CGPathRef path = CGPathCreateWithRect(self.bounds, NULL);
[self.borderLayer setPath:path];
CGPathRelease(path);
In the end this gives me a transparent UIView with a border around it. (In my concrete case it's a dashed line with an additional animation, but that doesn't matter for this particular question)
I played around with the shadow properties of CALayer, but they will always fill the whole layer.
self.borderLayer.shadowPath = self.borderLayer.path;
self.borderLayer.shouldRasterize = YES;
What I want is that only the UIViews surrounding line drops a shadow, so that the inside of the UIView remains transparent.
I was having similar problems seeing the shadow inside where I wanted it instead of a glow. I solved it by using two CALayers. One, in the code, '_bg' for the background ( in my case black with opacity of 0.55) and a white border. The other layer, in the code '_shadow', has a clear background and adds the glow effect. _bg is a subview of the _shadow layer. Here's the relevant code:
You can try something like this: