GithubHelp home page GithubHelp logo

wilsongramer / systemcolor Goto Github PK

View Code? Open in Web Editor NEW
8.0 0.0 1.0 14 KB

Use iOS 13's semantic UIColors on iOS 12 and under.

License: MIT License

Swift 100.00%
ios swift uikit uicolor semantic-colors ios13 hacktoberfest

systemcolor's Introduction

SystemColor

iOS 13 introduced semantic UIColors like .label, .systemBackground, etc. that will automatically adapt to light or dark mode. These colors aren't available to earlier versions of iOS, however, so to use them you'd have to litter your code with if #available everywhere.

To fix this, I generated a file that includes all of the new iOS 13 colors with light-themed fallbacks to support older iOS versions. To use it, just reference colors using the SystemColor type instead of UIColor and you should be good to go!

Installation

Add via Swift Package Manager:

.package(url: "SystemColor", .branch("master"))

Example

self.view.backgroundColor = SystemColor.systemBackground
self.label.textColor = SystemColor.label
// etc.

How did I make this?

I used a script to iterate over all of the new colors mentioned in the documentation, extracted their RGB values, and generated a Swift file with this information. You can check out the script in the generator.swift file.

Contributing

If I missed a color or Apple adds more, add them to the file and submit a pull request!

systemcolor's People

Contributors

wilsongramer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

moesn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.