checked & comment

This commit is contained in:
Kevin G Christiano 2020-09-30 15:54:51 -04:00
parent 108eca30db
commit 84a300eba7

View File

@ -368,14 +368,16 @@ public typealias ActionBlock = () -> ()
} }
/* /*
* This is to address a reuse issue beginning with iOS 13 (also present in iOS 14). * This is to address a reuse issue with iOS 13 and up.
* Even if you set text & attributedText to nil, the moment you set text with a value, * Even if you set text & attributedText to nil, the moment you set text with a value,
* attributedText will hold dirty value from a previously reused cell. * attributedText will hold a dirty value from a previously reused cell even if reset() is
* appropriately called.
* Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml
*/ */
if #available(iOS 13, *) { if #available(iOS 13, *) {
if labelModel.attributes == nil, let text = text { // Case where no attributes are set in the model but attributedText has a value.
let attributedString = NSMutableAttributedString(string: text, if labelModel.attributes == nil && attributedText != nil, let text = text {
attributes: [NSAttributedString.Key.font: font.updateSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) let attributedString = NSMutableAttributedString(string: text)
attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count)) attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count))
attributedText = attributedString attributedText = attributedString
} }