From 83cfbfb09dbc31a4e429f88efc516ba3782023a2 Mon Sep 17 00:00:00 2001 From: Charlie Scheer Date: Tue, 10 Sep 2024 20:14:26 -1000 Subject: [PATCH] Added convenience function to append attributed strings with color --- Simplenote/NSMutableAttributedString+Simplenote.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Simplenote/NSMutableAttributedString+Simplenote.swift b/Simplenote/NSMutableAttributedString+Simplenote.swift index 872e0ca99..f9a933f09 100644 --- a/Simplenote/NSMutableAttributedString+Simplenote.swift +++ b/Simplenote/NSMutableAttributedString+Simplenote.swift @@ -21,8 +21,13 @@ extension NSMutableAttributedString { /// Appends the specified String /// - func append(string: String) { - let string = NSAttributedString(string: string) + func append(string: String, foregroundColor: NSColor? = nil) { + var attributes = [NSAttributedString.Key: Any]() + if let foregroundColor = foregroundColor { + attributes[.foregroundColor] = foregroundColor + } + + let string = NSAttributedString(string: string, attributes: attributes) append(string) }