- Since iOS 13, UIKit and SwiftUI Color can be managed together
- You can formalize the transition between SwiftUI's Color and UIKit's UIColor in a cool way.
Check out the Example app for more details.
extension ColorAsset {
static let brandColor = ColorAsset(hex: "#88FF44")
static let primaryColor = ColorAsset(named: "primary", bundle: .module, alpha: 1)
}
struct ContentView: View {
var body: some View {
Text("Hello")
.foreground(Color(.brandColor)) // or .foreground(.asset(.brandColor))
}
}
let label = UILabel()
label.textColor = .asset(.brandColor)
Minimum Version | |
---|---|
Swift | 5.7 |
iOS | 13.0 |
macOS | 10.15 |
tvOS | 13.0 |
watchOS | 6.0 |
ColorAsset is only supported by Swift Package Manager.
To integrate ColorAsset into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift
:
dependencies: [
.package(url: "https://github.com/PRNDcompany/ColorAsset", from: "1.0.0"),
]
- Support DarkMode
- Support for multiple variants such as size classes
This library is released under the MIT license. See LICENSE for details.