ios - drawTextInRect: in UITextView class -
i use drawtextinrect: method in uitextfield class create outlined text (text black border/store effect).
but need similar create same outlined text in uitextview, drawtextinrect: method not included here. how can textview?
this code use in uitextfield class:
- (void)drawtextinrect:(cgrect)rect { cgcontextref c = uigraphicsgetcurrentcontext(); cgcontextsetlinewidth(c, 1); cgcontextsetlinejoin(c, kcglinejoinround); cgcontextsettextdrawingmode(c, kcgtextfill); self.textcolor = [uicolor whitecolor]; [super drawtextinrect:rect]; cgcontextsettextdrawingmode(c, kcgtextstroke); self.textcolor = [uicolor blackcolor]; [super drawtextinrect:rect]; }
how can create similar solution textview in uitextview class?
are targeting ios 6.0+? should work, perhaps:
nsattributedstring *yourstring = [[nsattributedstring alloc] initwithstring:@"your text" attributes:@{ nsstrokecolorattributename:[uicolor redcolor], nsstrokewidthattributename:[nsnumber numberwithfloat:1.0], nsfontattributename:[uifont systemfontofsize:24.0f] }]; yourtextfield.attributedtext = yourstring;
enjoy
Comments
Post a Comment