Skip to content

Instantly share code, notes, and snippets.

@maxcampolo
Created November 14, 2016 00:57
Show Gist options
  • Save maxcampolo/12c4272960d5355c05384dc64c236bfc to your computer and use it in GitHub Desktop.
Save maxcampolo/12c4272960d5355c05384dc64c236bfc to your computer and use it in GitHub Desktop.
Fit UILabel to font size
let label = UILabel()
label.bounds = CGRect(x: 0, y: 0, width: CGFloat(size), height: CGFloat(size))
label.font = UIFont(name: "AppleColorEmoji", size: CGFloat(size))
label.numberOfLines = 0
label.minimumScaleFactor = 0.01
label.adjustsFontSizeToFitWidth = true
label.lineBreakMode = .byTruncatingTail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment