Actual fix for links appearing as the wrong color

Closes #402
This commit is contained in:
Shadowfacts 2023-07-18 21:01:30 -07:00
parent 33999fe895
commit 105a01811a
1 changed files with 4 additions and 6 deletions

View File

@ -75,6 +75,10 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
textContainerInset = .zero textContainerInset = .zero
textContainer.lineFragmentPadding = 0 textContainer.lineFragmentPadding = 0
linkTextAttributes = [
.foregroundColor: UIColor.tintColor
]
// the text view's builtin link interaction code is tied to isSelectable, so we need to use our own tap recognizer // the text view's builtin link interaction code is tied to isSelectable, so we need to use our own tap recognizer
let recognizer = UITapGestureRecognizer(target: self, action: #selector(textTapped(_:))) let recognizer = UITapGestureRecognizer(target: self, action: #selector(textTapped(_:)))
addGestureRecognizer(recognizer) addGestureRecognizer(recognizer)
@ -94,12 +98,6 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
// MARK: - HTML Parsing // MARK: - HTML Parsing
func setTextFromHtml(_ html: String) { func setTextFromHtml(_ html: String) {
// this shouldn't be necessary, but sometimes when the text view is updated before
// being added to the view hierarchy, it doesn't get tintColorDidChange calld
// when it's actually added, so links have the wrong color
// see #402
self.tintColor = Preferences.shared.accentColor.color
self.attributedText = htmlConverter.convert(html) self.attributedText = htmlConverter.convert(html)
} }