ios - NSMutableattributed string not working for substring -
-(nsmutableattributedstring *)getattributedstringforstring:(nsstring *)totalstring filtertext:(nsstring *)filtertext font:(uifont *)titlefont backgroundcolor:(uicolor *)bcolor foregroundcolor:(uicolor *)fcolor { nsmutableattributedstring *attributedstring = nil; nsdictionary *filtertextattribute = @{nsbackgroundcolorattributename:bcolor, nsforegroundcolorattributename:fcolor, nsfontattributename: titlefont}; attributedstring = [[nsmutableattributedstring alloc] initwithstring:totalstring]; [attributedstring beginediting]; [attributedstring setattributes:filtertextattribute range:[totalstring rangeofstring:filtertext options:nscaseinsensitivesearch]]; [attributedstring endediting]; return attributedstring; }
i applying nsmutableattributedstring
filtertext in totalstring if filtertext totalstring above setattributes working otherwise not working substrings
Comments
Post a Comment