2

Hi want to highlight a substring from a string. I'm doing an app for Twitter and I want to highlight the usernames and hashtags and urls.I have the string and the substring captured.All I want is to highlight that substring from the string.

Edit: The problem is that I don't know how to get the range from that string,because I get that string over Twitter and I don't know it.Help me to get the range

 for user in tweet.userMentions{

                let userName:NSString = user.keyword
                var atrString = NSMutableAttributedString(string:tweetTextLabel.text!)
                atrString.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: //myproblem is here)
                tweetTextLabel.text = atrString

                }
        }
Stefan Scoarta
  • 781
  • 9
  • 21
  • 1
    possible duplicate of [How do you use NSAttributedString?](http://stackoverflow.com/questions/3482346/how-do-you-use-nsattributedstring) – Diego Freniche Apr 17 '15 at 09:13
  • What is the substring? Right now the Tweet is the only string and you're not using userName variable at all. Are you trying to highlight a part of the Tweet? – Automate This Apr 17 '15 at 13:19
  • Yes I'm trying to highlight a part of the tweet(usernames,urls,hashtags)Here it is for user – Stefan Scoarta Apr 17 '15 at 16:47

0 Answers0