added support for multiline labels

This commit is contained in:
Sebastian Mamczak 2017-08-03 11:25:31 +02:00
parent 7f395f6d05
commit 0185c6fd7c
1 changed files with 8 additions and 0 deletions

View File

@ -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 {