From 84a300eba73dacbfeabc5382b18c2001afbdaf80 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 30 Sep 2020 15:54:51 -0400 Subject: [PATCH] checked & comment --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 87939c52..fe6b31eb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -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, - * 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 labelModel.attributes == nil, let text = text { - let attributedString = NSMutableAttributedString(string: text, - attributes: [NSAttributedString.Key.font: font.updateSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) + // Case where no attributes are set in the model but attributedText has a value. + if labelModel.attributes == nil && attributedText != nil, let text = text { + let attributedString = NSMutableAttributedString(string: text) attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count)) attributedText = attributedString }