Skip to content

Instantly share code, notes, and snippets.

@letatas
Created September 11, 2019 12:31
Show Gist options
  • Save letatas/707c10b0a3ced8dd1e9176dfb78e8fde to your computer and use it in GitHub Desktop.
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.
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