In iOS 13, Apple introduced a bunch of new system colors (label, systemBackground, etc). These colors dynamically adapt to the preferred user interface style, but these colors aren't available on iOS < 13. ColorCompatibility is an autogenerated library which allows you to specify the system colors as static vars of the ColorCompatibility namespace, instead of UIColor. Using this will make colors "just work" on both iOS 13+ and iOS <= 12. On iOS <= 12, the colors default to Apple's light mode colors.
import ColorCompatibility myView.backgroundColor = ColorCompatibility.label
You can read more about this project here.
To run the example project, clone the repo, and run
pod install from the Example directory first.
ColorCompatibility is available through CocoaPods. To install it, simply add the following line to your Podfile:
If you'd prefer not to use Cocoapods, I recommend copy and pasting the
ColorCompatibility.swift code directly into your project. It's only one file
Noah Gilmore, https://noahgilmore.com/blog
ColorCompatibility is available under the MIT license. See the LICENSE file for more info.
If you see an issue, please report it via the GitHub issues tab. Pull requests are gladly accepted. You can get in touch with me on Twitter at https://twitter.com/noahsark769