Skip to content

Instantly share code, notes, and snippets.

@mukyasa
Last active May 2, 2020 04:12
Show Gist options
  • Save mukyasa/6711c8affbde9db82220eb30ea060d1b to your computer and use it in GitHub Desktop.
Save mukyasa/6711c8affbde9db82220eb30ea060d1b to your computer and use it in GitHub Desktop.
extension UIColor {
@Theme(light: UIColor.white,
dark: UIColor.safeSystemBackground)
static var background: UIColor
@Theme(light: UIColor(hex: "333333"),
dark: UIColor.safeLabel)
static var primaryText: UIColor
@Theme(light: UIColor(hex: "EEEFF2"),
dark: UIColor.safeSeperator)
static var seperator: UIColor
@Theme(light: UIColor(hex: "1F82FB"),
dark: UIColor(hex: "7C7FED"))
static var navBar: UIColor
}
// MARK: - BackPort iOS 13 and older Colors
extension UIColor {
static var safeSystemBackground: UIColor {
if #available(iOS 13, *) {
return .systemBackground
} else {
return .black
}
}
static var safeLabel: UIColor {
if #available(iOS 13, *) {
return .label
} else {
return .white
}
}
static var safeSeperator: UIColor {
if #available(iOS 13, *) {
return .separator
} else {
return UIColor.gray.withAlphaComponent(0.6)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment