ColorAsset

Swift Version Platforms License

为什么你应该使用 ColorAsset?

用法

查看 示例 应用以获取更多详细信息。

初始化

extension ColorAsset {
    static let brandColor = ColorAsset(hex: "#88FF44")
    static let primaryColor = ColorAsset(named: "primary", bundle: .module, alpha: 1)
}

在 SwiftUI 中

struct ContentView: View {
    var body: some View {
        Text("Hello")
            .foreground(Color(.brandColor)) // or .foreground(.asset(.brandColor))
    }
}

在 UIKit 或 AppKit 中

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 了解详细信息。