Created
September 11, 2019 12:31
-
-
Save letatas/707c10b0a3ced8dd1e9176dfb78e8fde to your computer and use it in GitHub Desktop.
UIColor extension to be used with the generated file representing the asset catalog parsed colors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIColor { | |
static func defaultColor(named name: String, default defaultColor: UIColor = .black) -> UIColor { | |
if #available(iOS 11, *) { | |
return UIColor(named: name) ?? defaultColor | |
} | |
else { | |
return _defaultColors[name] ?? defaultColor | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment