I'm new to iOS development.
I've got a label LatestInfo
this has text and is meant to have a link to a website: e.g. For the latest information visit example.com/latestInfo
I want the display to underline the url example.com/latestInfo
and make it clickable.
I am using Swift not Obejective-C
How can I go about doing this?
EDIT as per Pierre's request:
@IBOutlet weak var linkLabel: UITextView!
let string = "A great link : Google"
let range = (string as NSString).rangeOfString("Google")
let attributedString = NSMutableAttributedString(string: string)
attributedString.addAttribute(NSLinkAttributeName, value: NSURL("http://www.google.fr")!, range: range)
attributedString.addAttribute(NSUnderlineStyleAttributeName, value: NSNumber(int: 1), range: range)
attributedString.addAttribute(NSUnderlineColorAttributeName, value: UIColor.orangeColor(), range: range)
linkLabel.attributedText = attributedString