UIKitConfiguration 0.0.2

UIKitConfiguration 0.0.2

sakiyamaK 维护。



  • Kei Sakiyama

UIKitConfiguration

Swift Platforms Swift Package Manager Twitter

一个允许您使用通用 Configuration 设置 UIKit 参数的库

此库允许您在通用 Configuration 中设置 UIKit 参数。

import UIKit
import UIKitConfiguration

// setup UILabel Configuration
var labelConfiguration = UILabel.UIKitConfiguration()
labelConfiguration[\.textColor] = .white
labelConfiguration[\.font] = UIFont.systemFont(ofSize: 18, weight: .bold)
labelConfiguration[\.numberOfLines] = 0
labelConfiguration[\.backgroundColor] = .black

// apply UILabelConfiguration to UILabel
let label1 = UILabel(configuration: labelConfiguration)
label1.text = "label1 with labelConfiguration applied."

let label2 = UILabel(configuration: labelConfiguration)
label2.text = "label2 with labelConfiguration applied."

// setup UIImageView Configuration
var imageViewConfiguration = UIImageView.UIKitConfiguration()
imageViewConfiguration[\.backgroundColor] = .black
imageViewConfiguration[\.contentMode] = .scaleAspectFit
imageViewConfiguration[\.image] = UIImage(systemName: "swift")

// apply UIImageViewConfiguration to UIImageView
let imageView1 = UIImageView(configuration: imageViewConfiguration)
let imageView2 = UIImageView(configuration: imageViewConfiguration)

// Various other classes of UIKitConfiguration are available...

安装

Swift 包管理器

一旦您设置了 Swift 包,将 ObservableUIKit 作为依赖项添加就像将其添加到 Package.swift 的 dependencies 值一样简单。

dependencies: [
    .package(url: "https://github.com/sakiyamaK/UIKitConfiguration", .upToNextMajor(from: "0.0.1"))
]

要通过 Xcode 安装 ObservableUIKit 包

转到文件 -> Swift Packages -> 添加包依赖... 然后搜索 https://github.com/sakiyamaK/UIKitConfiguration 并选择您想要的版本

CocoaPods

CocoaPods 是 Cocoa 项目的依赖项管理器。有关使用和安装说明,请访问他们的网站。要使用 CocoaPods 将 ObservableUIKit 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

pod 'UIKitConfiguration'