Skip to content

Commit 522acd7

Browse files
committed
Make sure HTML mode also has proper colors for dark mode.
1 parent f67be52 commit 522acd7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Example/Example/EditorDemoController.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,15 @@ class EditorDemoController: UIViewController {
328328
textView.accessibilityLabel = accessibilityLabel
329329
textView.font = Constants.defaultContentFont
330330
textView.keyboardDismissMode = .interactive
331-
textView.textColor = UIColor(red: 0x1A/255.0, green: 0x1A/255.0, blue: 0x1A/255.0, alpha: 1)
331+
if #available(iOS 13.0, *) {
332+
textView.textColor = UIColor.label
333+
if let htmlStorage = textView.textStorage as? HTMLStorage {
334+
htmlStorage.textColor = UIColor.label
335+
}
336+
} else {
337+
// Fallback on earlier versions
338+
textView.textColor = UIColor(red: 0x1A/255.0, green: 0x1A/255.0, blue: 0x1A/255.0, alpha: 1)
339+
}
332340
textView.linkTextAttributes = [.foregroundColor: UIColor(red: 0x01 / 255.0, green: 0x60 / 255.0, blue: 0x87 / 255.0, alpha: 1), NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)]
333341
}
334342

0 commit comments

Comments
 (0)