Skip to content

Instantly share code, notes, and snippets.

@stleamist
Created February 16, 2020 01:23
Show Gist options
  • Select an option

  • Save stleamist/3b1b1c78e7fc9977d6dc34c82d00977e to your computer and use it in GitHub Desktop.

Select an option

Save stleamist/3b1b1c78e7fc9977d6dc34c82d00977e to your computer and use it in GitHub Desktop.
import UIKit
extension UIColor {
static func dynamicColor(light: UIColor, dark: UIColor) -> UIColor {
return UIColor { (traitCollection) -> UIColor in
if traitCollection.userInterfaceStyle != .dark {
return light
} else {
return dark
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment