update
This commit is contained in:
parent
0ba5da2add
commit
5bac63324f
@ -252,8 +252,6 @@ public typealias ActionBlock = () -> ()
|
||||
originalAttributedString = nil
|
||||
text = labelModel.text
|
||||
|
||||
print("SET before:\n \(attributedText)")
|
||||
|
||||
/*
|
||||
* 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,
|
||||
@ -262,15 +260,15 @@ public typealias ActionBlock = () -> ()
|
||||
* Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml
|
||||
*/
|
||||
if #available(iOS 13, *) {
|
||||
// Case where no attributes are set in the model but attributedText has a value.
|
||||
if let attributedText = attributedText, let text = text {
|
||||
let attributedString = NSMutableAttributedString(string: text)
|
||||
for attributes in attributedText.attributes(at: 0, effectiveRange: nil) {
|
||||
if attributes.key == .underlineStyle {
|
||||
attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count))
|
||||
let range = NSRange(location: 0, length: text.count)
|
||||
for attribute in attributedText.attributes(at: 0, effectiveRange: nil) {
|
||||
if attribute.key == .underlineStyle {
|
||||
attributedString.addAttribute(.underlineStyle, value: 0, range: range)
|
||||
}
|
||||
if attributes.key == .strikethroughStyle {
|
||||
attributedString.addAttribute(.strikethroughStyle, value: 0, range: NSRange(location: 0, length: text.count))
|
||||
if attribute.key == .strikethroughStyle {
|
||||
attributedString.addAttribute(.strikethroughStyle, value: 0, range: range)
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,8 +276,6 @@ public typealias ActionBlock = () -> ()
|
||||
}
|
||||
}
|
||||
|
||||
print("SET after:\n \(attributedText)")
|
||||
|
||||
hero = labelModel.hero
|
||||
Label.setLabel(self, withHTML: labelModel.html)
|
||||
isAccessibilityElement = hasText
|
||||
@ -394,9 +390,7 @@ public typealias ActionBlock = () -> ()
|
||||
|
||||
attributedText = attributedString
|
||||
originalAttributedString = attributedText
|
||||
print("SET new attribute:\n \(attributedText)")
|
||||
}
|
||||
print("SET DONE FUNC:\n \(attributedText)")
|
||||
}
|
||||
|
||||
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
@ -787,7 +781,6 @@ extension Label {
|
||||
public func reset() {
|
||||
text = nil
|
||||
attributedText = nil
|
||||
print("reset:\n \(attributedText)")
|
||||
hero = nil
|
||||
textAlignment = .left
|
||||
originalAttributedString = nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user