i want highlight text in uilabel
, have tried giving backgroundcolor
label, highlighting empty spaces looks not good. there way highlight text without resizing uilabel
.
please check image, here labels bigger text (center aligned)
thanx.
most of other solutions don't consider text spans multiple lines while still highlighting text, , pretty hacky involving subviews.
an ios 6 , later solution use attributed strings:
nsmutableattributedstring *s = [[nsmutableattributedstring alloc] initwithstring:yourstring]; [s addattribute:nsbackgroundcolorattributename value:[uicolor greencolor] range:nsmakerange(0, s.length)]; label.attributedtext = s;
Comments
Post a Comment