Any one knows how to do this? Having a custom cell, The sub label is a HTML snippet, with custom css classes that needs to be there to colour the text in specific places.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = self.tableView!.dequeueReusableCellWithIdentifier("SearchResCell", forIndexPath: indexPath) as! SearchResCell if self.searchStore != nil && self.searchStore.searchResult.count > 0 && self.searchStore.searchResult[0].searchResults.count > 0 { let searchRes = searchStore.searchResult[0].searchResults[indexPath.row] cell.titleLabel.text = searchRes.displayTitle cell.titleLabel.textColor = UIColor.blueColor() let attrResult = try! NSAttributedString( data: searchRes.wordsClean.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) cell.subtitleLabel.attributedText = attrResult cell.subtitleLabel.textAlignment = NSTextAlignment.Right } return cell } in the attrResult there is html with css class (lets say ABC ). Is there a way in the attributed string to say that is Foo class? or is there any other way except from using regex or string manipulation on every string that i get form the API? it can be hundreds and it is not my API so i can't change the HTML tags in it.
HTML Text Example:
bla bla bla <span class="HightlightTextClass"> highlighted text </span> more bla bra bra text "
10x