iphone - Add a shadow to CAShapeLayer, so that the inside remains transparent -


i want add glow effect path, blue glow around (os x) interface elements when have focus.

i used cashapelayer (rectangular) path:

self.borderlayer = [cashapelayer layer]; cgpathref path = cgpathcreatewithrect(self.bounds, null); [self.borderlayer setpath:path]; cgpathrelease(path); 

in end gives me transparent uiview border around it. (in concrete case it's dashed line additional animation, doesn't matter particular question)

i played around shadow properties of calayer, fill whole layer.

self.borderlayer.shadowpath = self.borderlayer.path; self.borderlayer.shouldrasterize = yes; 

what want uiviews surrounding line drops shadow, inside of uiview remains transparent.

i having similar problems seeing shadow inside wanted instead of glow. solved using 2 calayers. one, in code, '_bg' background ( in case black opacity of 0.55) , white border. other layer, in code '_shadow', has clear background , adds glow effect. _bg subview of _shadow layer. here's relevant code:

_bg = [calayer layer]; _shadow = [calayer layer];  [self.layer insertsublayer:_shadow atindex:0]; [_shadow addsublayer:_bg];  _bg.frame = self.bounds; _bg.backgroundcolor = [uicolor colorwithred:0.0 green:0.0 blue:0.0 alpha:.55].cgcolor; _bg.cornerradius=20.0; _bg.bordercolor=[uicolor whitecolor].cgcolor; _bg.borderwidth=2.0;  _shadow.frame=self.bounds; _shadow.maskstobounds=no; _shadow.backgroundcolor = [uicolor clearcolor].cgcolor; _shadow.cornerradius=3.0; _shadow.shadowradius=3.0; _shadow.shadowcolor=[uicolor whitecolor].cgcolor; _shadow.shadowopacity=0.6; _shadow.shadowoffset=cgsizemake(0.0, 0.0); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -