update
This commit is contained in:
parent
0ba5da2add
commit
5bac63324f
@ -252,8 +252,6 @@ public typealias ActionBlock = () -> ()
|
|||||||
originalAttributedString = nil
|
originalAttributedString = nil
|
||||||
text = labelModel.text
|
text = labelModel.text
|
||||||
|
|
||||||
print("SET before:\n \(attributedText)")
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is to address a reuse issue with iOS 13 and up.
|
* 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,
|
||||||
@ -262,15 +260,15 @@ public typealias ActionBlock = () -> ()
|
|||||||
* Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml
|
* Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml
|
||||||
*/
|
*/
|
||||||
if #available(iOS 13, *) {
|
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 {
|
if let attributedText = attributedText, let text = text {
|
||||||
let attributedString = NSMutableAttributedString(string: text)
|
let attributedString = NSMutableAttributedString(string: text)
|
||||||
for attributes in attributedText.attributes(at: 0, effectiveRange: nil) {
|
let range = NSRange(location: 0, length: text.count)
|
||||||
if attributes.key == .underlineStyle {
|
for attribute in attributedText.attributes(at: 0, effectiveRange: nil) {
|
||||||
attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count))
|
if attribute.key == .underlineStyle {
|
||||||
|
attributedString.addAttribute(.underlineStyle, value: 0, range: range)
|
||||||
}
|
}
|
||||||
if attributes.key == .strikethroughStyle {
|
if attribute.key == .strikethroughStyle {
|
||||||
attributedString.addAttribute(.strikethroughStyle, value: 0, range: NSRange(location: 0, length: text.count))
|
attributedString.addAttribute(.strikethroughStyle, value: 0, range: range)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,8 +276,6 @@ public typealias ActionBlock = () -> ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print("SET after:\n \(attributedText)")
|
|
||||||
|
|
||||||
hero = labelModel.hero
|
hero = labelModel.hero
|
||||||
Label.setLabel(self, withHTML: labelModel.html)
|
Label.setLabel(self, withHTML: labelModel.html)
|
||||||
isAccessibilityElement = hasText
|
isAccessibilityElement = hasText
|
||||||
@ -394,9 +390,7 @@ public typealias ActionBlock = () -> ()
|
|||||||
|
|
||||||
attributedText = attributedString
|
attributedText = attributedString
|
||||||
originalAttributedString = attributedText
|
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]?) {
|
@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() {
|
public func reset() {
|
||||||
text = nil
|
text = nil
|
||||||
attributedText = nil
|
attributedText = nil
|
||||||
print("reset:\n \(attributedText)")
|
|
||||||
hero = nil
|
hero = nil
|
||||||
textAlignment = .left
|
textAlignment = .left
|
||||||
originalAttributedString = nil
|
originalAttributedString = nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user