p-x9/swiftuicolor
Make system color defined in `UIColor`/`NSColor` available to SwiftUI Color.
Usage
- import
``swift import SwiftUIColor ``
- Use
Get the color for each platform ```swift // universal system colors let color = Color.universal.systemRed
// iOS system colors let color = Color.iOS.systemBackground
// macOS system colors let color = Color.macOS.secondarySystemFillColor
// and watchOS, tvOS... ```
Another Style ```swift // universal system colors let color: Color = .universal(.systemRed)
// iOS system colors let color: Color = .iOS(systemBackground)
// macOS system colors let color: Color = macOS(.secondarySystemFillColor)
// and watchOS, tvOS... ```
list of colors ```swift // universal color list let colors: [Color] = Color.universal.colors
list of color names ``swift // universal color name list let colors: [Color] = Color.universal.colorNames ``
Example
| universal | iOS | macOS | | ---- | ---- | ---- | | [universal] | [iOS] | [macOS] |
| tvOS | watchOS | | ---- | ---- | | [tvOS] | [watchOS] |
Development
In this library, colors are defined in an asset file. <img width="1379" alt="image" src="https://user-images.githubusercontent.com/50244599/197352199-499cec35-bc47-43ae-8fe4-9b785cab1faa.png">
Based on this asset file, the following code is generated.
<img width="1379" alt="image" src="https://user-images.githubusercontent.com/50244599/197352377-13e2b057-f389-468a-9659-a7240d0b4c2c.png">
If you have updated the asset file, use the following command to update the code
swift run -c release --package-path . prepare-swiftui-color Sources/SwiftUIColor/Assets/Media.xcassets/ Sources/SwiftUIColor/License
SwiftUIColor is released under the MIT License. See LICENSE
Package Metadata
Repository: p-x9/swiftuicolor
Default branch: main
README: README.md