Merge pull request #35 from smamczak/multiline-labels-support

added support for multiline labels
This commit is contained in:
Xavier Schott 2018-06-01 13:04:14 -07:00 committed by GitHub
commit f4b8fc697f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {