ios - shadow in UILabel -
i tried subclassing uilabel following code.. unable similar
- (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;
Comments
Post a Comment