From 74820e8922600eee84d7cd85a24935b8316e5831 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 24 Oct 2023 15:11:14 -0400 Subject: [PATCH] Underline links when button shapes accessibility setting is on --- Tusker/Views/ContentTextView.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tusker/Views/ContentTextView.swift b/Tusker/Views/ContentTextView.swift index 0a544121..a2c61180 100644 --- a/Tusker/Views/ContentTextView.swift +++ b/Tusker/Views/ContentTextView.swift @@ -78,10 +78,21 @@ class ContentTextView: LinkTextView, BaseEmojiLabel { linkTextAttributes = [ .foregroundColor: UIColor.tintColor ] + updateLinkUnderlineStyle() // 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(_:))) addGestureRecognizer(recognizer) + + NotificationCenter.default.addObserver(self, selector: #selector(updateLinkUnderlineStyle), name: UIAccessibility.buttonShapesEnabledStatusDidChangeNotification, object: nil) + } + + @objc private func updateLinkUnderlineStyle() { + if UIAccessibility.buttonShapesEnabled { + linkTextAttributes[.underlineStyle] = NSUnderlineStyle.single.rawValue + } else { + linkTextAttributes.removeValue(forKey: .underlineStyle) + } } // MARK: - Emojis