From 0185c6fd7c5f5d82a58e88828eccf3eb4e97d2f1 Mon Sep 17 00:00:00 2001 From: Sebastian Mamczak Date: Thu, 3 Aug 2017 11:25:31 +0200 Subject: [PATCH] added support for multiline labels --- TGPControls/TGPCamelLabels.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TGPControls/TGPCamelLabels.swift b/TGPControls/TGPCamelLabels.swift index 0d9f6e5..9a56aa2 100644 --- a/TGPControls/TGPCamelLabels.swift +++ b/TGPControls/TGPCamelLabels.swift @@ -99,6 +99,12 @@ public class TGPCamelLabels: UIControl { } } + @IBInspectable public var numberOfLinesInLabel:Int = 1 { + didSet { + layoutTrack() + } + } + // Label off-center to the left and right of the slider // expressed in label width. 0: none, -1/2: half outside, 1/2; half inside @IBInspectable public var offCenter:CGFloat = 0 { @@ -252,6 +258,7 @@ public class TGPCamelLabels: UIControl { let centerY = bounds.height / 2.0 for name in names { let upLabel = UILabel.init() + upLabel.numberOfLines = self.numberOfLinesInLabel emphasizedLabels.append(upLabel) upLabel.text = name if let upFontName = upFontName { @@ -275,6 +282,7 @@ public class TGPCamelLabels: UIControl { addSubview(upLabel) let dnLabel = UILabel.init() + dnLabel.numberOfLines = self.numberOfLinesInLabel regularLabels.append(dnLabel) dnLabel.text = name if let downFontName = downFontName {