Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension UILabel {
- func willTruncate() -> Bool {
- guard let labelText = text else {
- return false
- }
- let mText = labelText as NSString
- let attributes = [NSFontAttributeName : font]
- let labelSize = mText.boundingRectWithSize(CGSize(width: bounds.width, height: CGFloat.max), options: .UsesLineFragmentOrigin, attributes: attributes, context: nil)
- return Int(ceil(CGFloat(labelSize.height) / font.lineHeight)) > numberOfLines
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement