From 4a7dfbcc9215f1dbaf0f98ce24b76e389edb79c1 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 8 Mar 2024 12:15:55 -0600 Subject: [PATCH] Statically define the accent color so that it doesn't regularly do the lookup --- VinUtility/Sources/VinUtility/UIColor+VU.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/VinUtility/Sources/VinUtility/UIColor+VU.swift b/VinUtility/Sources/VinUtility/UIColor+VU.swift index 20eb9020..768369a6 100644 --- a/VinUtility/Sources/VinUtility/UIColor+VU.swift +++ b/VinUtility/Sources/VinUtility/UIColor+VU.swift @@ -7,16 +7,18 @@ import UIKit public extension UIColor { - + + static var definedAccentColor = UIColor(named: "AccentColor")! + static var accentColor: UIColor { guard let systemHighlightColor = UserDefaults.standard.string(forKey: "AppleHighlightColor"), - let colorName = systemHighlightColor.components(separatedBy: " ").last else { return UIColor(named: "AccentColor")! } + let colorName = systemHighlightColor.components(separatedBy: " ").last else { return .definedAccentColor } guard colorName != "Graphite" else { return UIColor.systemGray } let selector = NSSelectorFromString(NSString.localizedStringWithFormat("system%@Color", colorName) as String) guard UIColor.responds(to: selector) else { return UIColor(named: "AccentColor")! } - return UIColor.perform(selector).takeUnretainedValue() as? UIColor ?? UIColor(named: "AccentColor")! + return UIColor.perform(selector).takeUnretainedValue() as? UIColor ?? .definedAccentColor } var isDefaultAccentColor: Bool {