查看 示例 应用以获取更多详细信息。
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)
最低版本 | |
---|---|
Swift | 5.7 |
iOS | 13.0 |
macOS | 10.15 |
tvOS | 13.0 |
watchOS | 6.0 |
ColorAsset 仅支持 Swift Package Manager。
要使用 Swift Package Manager 将 ColorAsset 集成到你的 Xcode 项目中,请将其添加到你的 Package.swift
的 dependencies 值中
dependencies: [
.package(url: "https://github.com/PRNDcompany/ColorAsset", from: "1.0.0"),
]
此库在 MIT 许可下发布。 请参阅 LICENSE 了解详细信息。