Skip to content

Commit

Permalink
Limited dynamic UIColor constructor to iOS and tvOS
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermomuntaner committed Sep 25, 2019
1 parent d0ae633 commit 309dbe1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/DynamicUIColor/DynamicUIColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ public struct DynamicUIColor {
case .dark: return dark
case .light: return light
case .none:
// UIColor(dynamicProvider:) only available on iOS >=13+ & tvOS >=13
#if os(iOS) || os(tvOS)
if #available(iOS 13.0, tvOS 13.0, *) {
return UIColor { traitCollection in
return UIColor { traitCollection -> UIColor in
switch traitCollection.userInterfaceStyle {
case .dark: return self.dark
case .light, .unspecified: return self.light
Expand All @@ -83,6 +85,9 @@ public struct DynamicUIColor {
} else {
return light
}
#else
return light
#endif
}
}
}
Expand Down

0 comments on commit 309dbe1

Please sign in to comment.