Underline links when button shapes accessibility setting is on

This commit is contained in:
Shadowfacts 2023-10-24 15:11:14 -04:00
parent f7a9075b77
commit 74820e8922
1 changed files with 11 additions and 0 deletions

View File

@ -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