From e50a8e0a59d9bfd30005dec1f31f03a0719b7962 Mon Sep 17 00:00:00 2001 From: Alanc Liu Date: Tue, 2 May 2017 12:20:41 +0800 Subject: [PATCH] Fix incorrect size issue Modify the function of getting size to make it right. --- LiveLabel/LiveLabel/LyricLabel.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/LiveLabel/LiveLabel/LyricLabel.swift b/LiveLabel/LiveLabel/LyricLabel.swift index fd3c8a9..94587a0 100644 --- a/LiveLabel/LiveLabel/LyricLabel.swift +++ b/LiveLabel/LiveLabel/LyricLabel.swift @@ -46,7 +46,10 @@ class LyricLabel: UILabel { override func draw(_ rect: CGRect) { super.draw(rect) - var size = self.frame.size + let myString: NSString = self.text! as NSString + var size: CGSize = myString.size(attributes: [NSFontAttributeName: UIFont.boldSystemFont(ofSize: self.font.pointSize)]) + size.height = rect.height; +// var size = rect.size; // Draw solid color filled image size.width = max(1, size.width * (CGFloat(progress) * 0.01))