iOS 13/14 issue fix.
This commit is contained in:
parent
183afe1eca
commit
108eca30db
@ -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]?) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user