Swiftpack.co - Package - rosberry/DarkMode

Dark Mode

Swift Version Carthage Compatible Swift Package Manager

DarkMode is a small framework that simplify configuration of light and dark user interface styles and reduce checks of available SDKs.


  • iOS 12.0+ / tvOS 12.0+
  • Xcode 10.0+


DarkMode contains 6 extensions of UIKit components.

  1. UIColor extension contains an initializer with light and dark colors:

    static let layer = UIColor(light: .init(red: 106 / 255, green: 32 / 255, blue: 119 / 255, alpha: 1),
                               dark: .init(red: 138 / 255, green: 76 / 255, blue: 146 / 255, alpha: 1))
  2. UIImageAsset extension contains an initializer with light and dark images:

    let imageAsset = UIImageAsset(lightModeImage: UIImage(named: "RedRectangle"),
                                  darkModeImage: UIImage(named: "GreenRectangle"))
  3. UITraitCollection extension has optional check of different color appearance:

    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        traitCollection.performForDifferentColorAppearance(comparedTo: previousTraitCollection) {
            //update related colors
  4. UIWindow extension allows you to override user interface style without SDK checks:

  5. UIApplication extension allows you to override user interface style for all windows without SDK checks:

  6. UserDefaults extension allows you to save overrides user interface style:

    UserDefaults.standard.overridedUserInterfaceStyle = .dark

To see how it works together, please check DarkModeExample project.



Create a Cartfile that lists the framework and run carthage update. Follow the instructions to add the framework to your project.

github "rosberry/DarkMode"


Drag DarkMode Swift files from last release into your project.


This project is owned and maintained by Rosberry. We build mobile apps for users worldwide 🌏.

Check out our open source projects, read our blog or give us a high-five on 🐦 @rosberryapps.


DarkMode is available under the MIT license. See the LICENSE file for more info.


Stars: 3


Used By

Total: 0