Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. extension UILabel {
  2.  
  3. func willTruncate() -> Bool {
  4. guard let labelText = text else {
  5. return false
  6. }
  7. let mText = labelText as NSString
  8. let attributes = [NSFontAttributeName : font]
  9. let labelSize = mText.boundingRectWithSize(CGSize(width: bounds.width, height: CGFloat.max), options: .UsesLineFragmentOrigin, attributes: attributes, context: nil)
  10. return Int(ceil(CGFloat(labelSize.height) / font.lineHeight)) > numberOfLines
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement