SwiftUIColor

0.4.0

🎨 Make system color defined in UIColor/NSColor available to SwiftUI Color.
p-x9/SwiftUIColor

What's New

v0.4.0

2023-09-20T02:33:04Z

What's Changed

  • New writing style by @p-x9 in #15
    let color: Color = .iOS(systemBackground)
    
    // The existing writing method can be used at the same time. 
    let color: Color = Color.iOS.systemBackground

Full Changelog: 0.3.0...0.4.0

SwiftUIColor

Make system color defined in UIColor/NSColor available to SwiftUI Color.

Usage

  1. import

    import SwiftUIColor
  2. 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

Example

universal iOS macOS
universal iOS macOS
tvOS watchOS
tvOS watchOS

Development

In this library, colors are defined in an asset file. image

Based on this asset file, the following code is generated.

image

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

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Apr 27 2024 01:49:19 GMT-0900 (Hawaii-Aleutian Daylight Time)