how change text color of particular word of textview text in ios5.i have implemented app in displayed mangalashtak shlok in textview .it has play button plays audio file of mangal ashtak.now want synchronise audio file textview .i have implemented using nsmutableattributedstring in ios 6 below
if(seconds>=42 && seconds<43) { nsmutableattributedstring * string = [[nsmutableattributedstring alloc]initwithstring:self.textview.text]; nsstring *word= [shlok2 objectatindex:0]; //array shlok 2 contains each word of shlok nslog(@"%@",word); nsrange range=[self.textview.text rangeofstring:word]; [string addattribute:nsforegroundcolorattributename value:[uicolor whitecolor] range:range]; [self.textview setattributedtext:string]; [textview setfont:[uifont systemfontofsize:16]]; } using above code changed color of text audio file .in play button action checked current timing of avaudioplayer object & changed respective text .but in ios 5 doesn't work?
support attributed strings in uikit classes uitextview added in ios 6. on earlier systems have draw strings using core text or framework dtcoretext.
Comments
Post a Comment