Merge pull request #7174 from vector-im/mauroromito/fix_formatted_links_ios16

Fix for formatted links that appear in black that works also on iOS 16
This commit is contained in:
Velin92
2022-12-15 16:37:01 +01:00
committed by GitHub
@@ -51,10 +51,6 @@ class HTMLFormatter: NSObject {
DTDefaultFontName: font.fontName,
DTDefaultFontSize: font.pointSize,
DTDefaultLinkDecoration: false,
/* This fixes the issue where links are displayed in black
on DTCoreText 1.6.26, the provided value does not matter
the tintColor of the UI element will be used for links */
DTDefaultLinkColor: "",
DTWillFlushBlockCallBack: sanitizeCallback
]
options.merge(extraOptions) { (_, new) in new }
@@ -66,7 +62,11 @@ class HTMLFormatter: NSObject {
let mutableString = NSMutableAttributedString(attributedString: string)
MXKTools.removeDTCoreTextArtifacts(mutableString)
postFormatOperations?(mutableString)
// Remove CTForegroundColorFromContext attribute to fix the iOS 16 black link color issue
// REF: https://github.com/Cocoanetics/DTCoreText/issues/792
mutableString.removeAttribute(NSAttributedString.Key("CTForegroundColorFromContext"), range: NSRange(location: 0, length: mutableString.length))
return mutableString
}