From 97523b581823275a8369f13a66efab00c4ae8e6e Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Mon, 26 Jun 2017 12:08:31 +0300 Subject: [PATCH] [MAPSME-4676] [ios] Added numberOfVisibleLines to UILabel. --- iphone/Maps/Categories/UILabel+NumberOfVisibleLines.swift | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 iphone/Maps/Categories/UILabel+NumberOfVisibleLines.swift diff --git a/iphone/Maps/Categories/UILabel+NumberOfVisibleLines.swift b/iphone/Maps/Categories/UILabel+NumberOfVisibleLines.swift new file mode 100644 index 0000000000..eeee79c6bd --- /dev/null +++ b/iphone/Maps/Categories/UILabel+NumberOfVisibleLines.swift @@ -0,0 +1,8 @@ +extension UILabel { + var numberOfVisibleLines: Int { + let textSize = CGSize(width: frame.size.width, height: CGFloat(MAXFLOAT)) + let rowHeight = sizeThatFits(textSize).height.rounded() + let charHeight = font.pointSize.rounded() + return Int((rowHeight / charHeight).rounded()) + } +}