ios4 - uilabel with outline or stroke -
this question has answer here:
- how make uilabel display outlined text? 11 answers
i wondering how can create text stroke uilabel ? there possible way ?
thank ,
#import <foundation/foundation.h> @interface customlabel : uilabel { } @end #import "customlabel.h" @implementation customlabel - (void)drawtextinrect:(cgrect)rect { cgsize shadowoffset = self.shadowoffset; uicolor *textcolor = self.textcolor; cgcontextref c = uigraphicsgetcurrentcontext(); cgcontextsetlinewidth(c, 22); cgcontextsettextdrawingmode(c, kcgtextstroke); self.textcolor = [uicolor whitecolor]; [super drawtextinrect:rect]; cgcontextsettextdrawingmode(c, kcgtextfill); self.textcolor = textcolor; self.shadowoffset = cgsizemake(0, 0); [super drawtextinrect:rect]; self.shadowoffset = shadowoffset; //works fine no warning }
now question how can use subclass iboutlet label on different viewcontrollers . right :
label = [[customlabel alloc] initwithframe:cgrectmake(0, 0, 190, 190)];
it may helpful add depending on font , characters, adding:
cgcontextsetlinejoin(c,kcglinejoinround);
can prevent artifacts large stroke applied sharp character.
Comments
Post a Comment