'【UILabel】"set text" is too slow
When setting UILabel.text to a string with many line breaks, it takes too much time.
Why is this?
Is there a solution?
@IBOutlet weak var textArea: UITextView!
@IBOutlet weak var label: UILabel!
@IBAction func tap(_ sender: Any) {
var longTextWithLineBreaks = "";
for _ in 0 ..< 50000 {
longTextWithLineBreaks += "1\n"
}
var longText = "";
for _ in 0 ..< 50000 {
longText += "12"
}
// UITextView
self.textArea.text = longTextWithLineBreaks; // fast
self.textArea.text = longText; // fast
// UILabel
self.label.text = longTextWithLineBreaks; // too slow!!!!!! why???? processing time has minute over, CPU 100%
self.label.text = longText; // fast ^^
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
