diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 748013f0..87939c52 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -247,6 +247,7 @@ public typealias ActionBlock = () -> () return } + text = nil attributedText = nil originalAttributedString = nil text = labelModel.text @@ -365,6 +366,20 @@ public typealias ActionBlock = () -> () attributedText = attributedString originalAttributedString = attributedText } + + /* + * This is to address a reuse issue beginning with iOS 13 (also present in iOS 14). + * 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. + */ + 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]) + attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count)) + attributedText = attributedString + } + } } @objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {