Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bogren/DeviceColor
💅 iOS device color in Swift
https://github.com/bogren/DeviceColor
Last synced: 3 months ago
JSON representation
💅 iOS device color in Swift
- Host: GitHub
- URL: https://github.com/bogren/DeviceColor
- Owner: bogren
- License: mit
- Created: 2016-08-06T17:03:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-27T10:44:18.000Z (almost 8 years ago)
- Last Synced: 2024-05-02T12:40:39.448Z (7 months ago)
- Language: Swift
- Size: 8.79 KB
- Stars: 25
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeviceColor
⚠️ Don't use this code in production - device color is part of the private API ⚠️
## About
My favorite addition to demo apps or hackathon projects is to add different color schemes for different device colors. Can be achieved easily in Objective-C using the private api. (Please note you should **not** publish apps using the private api).
Note it's possible to accomplish the same results with a bridging header, but I wanted a 'pure' Swift solution. Inspiration and help from this stackoverflow [post](http://stackoverflow.com/a/35231921/3729825).
If someone know or created a public color scheme for all different devices please ping me. I'd like to add it to my example project.
## Usage
Fork or download the project, put the extension `UIDevice+DeviceColor.swift` in your own project, get the color using `UIDevice.current.deviceInfoForKey(key: "DeviceEnclosureColor")` or `UIDevice.current.deviceInfoForKey(key: "DeviceColor")`. the returned string can be parsed with an extension to UIcolor e.g [arshad's gist](https://gist.github.com/arshad/de147c42d7b3063ef7bc) or similar.
Preferably you want to check if the method is available before calling the method to avoid crashes if the API changes.
## Acknowledgment
Check out [ortwingentz](https://twitter.com/ortwingentz)'s example [project](https://github.com/futuretap/DeviceColors) in Objective-C. He also made a collection of device colors 🙌! Also, please dupe his [radar](http://www.openradar.me/15209345), hopefully we get to use the device color in future iOS versions.
## License
MIT, see `LICENSE.md`