Skip to content

Commit

Permalink
adds link label to demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hart authored and Andrew Hart committed Nov 24, 2015
1 parent 35c9a85 commit 70c3e60
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions LinkLabelDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

self.view.backgroundColor = UIColor.whiteColor()

let text = "This is some text, which incidentally includes a link you may find interesting."
let fullRange = NSMakeRange(0, (text as NSString).length)
let linkRange = (text as NSString).rangeOfString("includes a link")
let attributedString = NSMutableAttributedString(string: text)
attributedString.addAttribute(NSFontAttributeName, value: UIFont.systemFontOfSize(15), range: fullRange)
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.blackColor(), range: fullRange)
attributedString.addAttribute(NSLinkAttributeName, value: NSURL(string: "https://google.com")!, range: linkRange)

let label = LinkLabel()
label.numberOfLines = 0 // Infinite lines
label.attributedText = attributedString
label.frame = CGRect(x: 20, y: 20, width: 280, height: 400)
self.view.addSubview(label)
}

override func didReceiveMemoryWarning() {
Expand Down

0 comments on commit 70c3e60

Please sign in to comment.