Make system color defined in UIColor
/NSColor
available to SwiftUI Color.
import
import SwiftUIColor
Use
Get the color for each platform
// 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
// 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
// universal color list
let colors: [Color] = Color.universal.colors
list of color names
```swift
// universal color name list
let colors: [Color] = Color.universal.colorNames
universal | iOS | macOS |
---|---|---|
tvOS | watchOS |
---|---|
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
swift run -c release --package-path . prepare-swiftui-color Sources/SwiftUIColor/Assets/Media.xcassets/ Sources/SwiftUIColor/
SwiftUIColor is released under the MIT License. See LICENSE