ios - shadow in UILabel -


i tried subclassing uilabel following code.. unable similar label dropshadow

- (void) drawrect:(cgrect)rect {     cgsize myshadowoffset = cgsizemake(4, -4);     cgfloat mycolorvalues[] = {0, 0, 0, .8};      cgcontextref mycontext = uigraphicsgetcurrentcontext();     cgcontextsavegstate(mycontext);      cgcolorspaceref mycolorspace = cgcolorspacecreatedevicergb();     cgcolorref mycolor = cgcolorcreate(mycolorspace, mycolorvalues);     cgcontextsetshadowwithcolor (mycontext, myshadowoffset, 5, mycolor);      self.layer.shadowoffset = cgsizemake(0, 1);     self.layer.shadowopacity = 0.5;     self.shadowcolor = [uicolor blackcolor];      [super drawtextinrect:rect];      cgcolorrelease(mycolor);     cgcolorspacerelease(mycolorspace);      cgcontextrestoregstate(mycontext); } 

self.layer.shadowoffset = cgsizemake(0, -2.5); self.layer.shadowradius = 1; self.layer.shadowopacity = 0.5; self.layer.shadowcolor = [uicolor blackcolor].cgcolor; 

here output


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -