Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/p-x9/swiftuicolor
🎨 Make system color defined in UIColor/NSColor available to SwiftUI Color.
https://github.com/p-x9/swiftuicolor
ios macos plugin swift swiftpackage swiftui
Last synced: 4 months ago
JSON representation
🎨 Make system color defined in UIColor/NSColor available to SwiftUI Color.
- Host: GitHub
- URL: https://github.com/p-x9/swiftuicolor
- Owner: p-x9
- License: mit
- Created: 2022-10-22T14:13:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T12:36:41.000Z (9 months ago)
- Last Synced: 2024-04-24T14:10:09.450Z (9 months ago)
- Topics: ios, macos, plugin, swift, swiftpackage, swiftui
- Language: Swift
- Homepage:
- Size: 158 KB
- Stars: 22
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftUIColor
Make system color defined in `UIColor`/`NSColor` available to SwiftUI Color.
## Usage
1. import
```swift
import SwiftUIColor
```
2. UseGet 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.colorslist of color names
```swift
// universal color name list
let colors: [Color] = Color.universal.colorNames
```## Example
| universal | iOS | macOS |
| ---- | ---- | ---- |
| ![universal](https://user-images.githubusercontent.com/50244599/213266065-c2a80ef4-4612-4684-b03a-2d5ed424358a.PNG) | ![iOS](https://user-images.githubusercontent.com/50244599/213266082-b09044df-5b45-408e-a1e7-84c055777f63.PNG) | ![macOS](https://user-images.githubusercontent.com/50244599/213266087-daf724fd-2142-4b96-b00c-cfc47a2b7a63.PNG) || tvOS | watchOS |
| ---- | ---- |
| ![tvOS](https://user-images.githubusercontent.com/50244599/213266103-99a41ad1-4154-4ec1-99c8-aae210aceb4e.PNG) | ![watchOS](https://user-images.githubusercontent.com/50244599/213266108-bc9c1ce9-982f-441a-91a4-d4c03f179204.PNG) |## Development
In this library, colors are defined in an asset file.Based on this asset file, the following code is generated.
If you have updated the asset file, use the following command to update the code
```sh
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](./LICENSE)