ios - #tag suggested UITextView with attributed text while editing -
i working on app in using wutextsuggestioncontroller #tag suggested textview can check controller here https://github.com/yuao/wutextsuggestion. works fine when start typeing # or @ ,it gives right result.
now question is,how change color of #tag vlaue in uitextview means when type "#test students",then #test in different color , remaining text in regular color.
any help,any small suggestions welcome.
i hope may , sort out problem
-(bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range replacementtext:(nsstring *)text{ { nsmutableattributedstring * string = [[nsmutableattributedstring alloc]initwithstring:textview.text]; if([text isequaltostring:@"#"]){ nsrange range=[textview.text rangeofstring:text]; [string addattribute:nsforegroundcolorattributename value:[uicolor redcolor] range:range]; } [self.text setattributedtext:string]; }
Comments
Post a Comment