Skip to content

Instantly share code, notes, and snippets.

@crazytonyli
Last active September 28, 2015 14:34
Show Gist options
  • Save crazytonyli/614f12adef7c0562bade to your computer and use it in GitHub Desktop.
Save crazytonyli/614f12adef7c0562bade to your computer and use it in GitHub Desktop.
let text = "01234567890123456789012345678901234567890123456789"
let attributedText = NSMutableAttributedString(string: "\(text)😈πŸ˜₯😈πŸ˜₯😈πŸ˜₯😈πŸ˜₯")
attributedText.setAttributes([NSForegroundColorAttributeName: UIColor.blueColor()],
range: NSMakeRange(0, text.characters.count))
let label = UILabel(frame: CGRectMake(0, 0, 320, 320))
label.attributedText = attributedText
label.lineBreakMode = .ByTruncatingMiddle
label.numberOfLines = 2
label.sizeThatFits(label.bounds.size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment