objective c - Change UIPicker's row color or row text color -
i have uipicker
i'm using toggle layers on , off. want able either change color of row within picker indicate if layer on, or change font color of text indicate if layer on.
if neither possible, append nsstring
add x @ end of before return (so "streets" become "streets x" if layer on). i'm not sure how either. know can type of buffing number, not sure nsstring
. know picker can display 27 characters, maybe set string length 26 , set char @ location 26 x? don't know how set length of string.
any ideas either path?
for custom rows in uipickerview have implement pickerview:viewforrow:forcomponent:reusingview:
instead of pickerview:titleforrow:forcomponent:
.
in case you'd use uilabel
view, , change text colour , text string each row.
assuming have 1 component:
- (uiview *)pickerview:(uipickerview *)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component reusingview:(uiview *)view { uilabel *label; if (!view) // no view re-use, create new 1 label = [[uilabel alloc] initwithframe://your frame here]; else label = (uilabel*)view; label.text = // row text here if (//some flag indicate row selected) label.textcolor = [uicolor redcolor]; else label.textcolor = [uicolor blackcolor]; return label; }
Comments
Post a Comment