BRFluentModule 1.0.0

BRFluentModule 1.0.0

ck2shine 维护。



  • 作者:ck2shine
  • ck2shine/BRFluentModule

BRFluentModule

Carthage compatible SPM supported

BRFluentModule 是一个简单的 Swift 包装器,用于创建具有流畅界面的 Swift 对象,就像 SwiftUI 一样。

  • 在 SwiftUI 中,可以写成如下形式:
    Text("Shine")
        .frame(width: 100)
        .border(Color.red)
        .opacity(0.3)

使用这个包装器,可以编写具有流畅界面的 Swift 对象。

需求

版本 操作系统 Swift
1.0.0 iOS 11+ , macOS 10.14+ , watchOS 6+ 5.1

安装

Carthage

BRFluentModule 通过 Carthage 提供。要安装,只需将以下行添加到 Cartfile 即可:

github "ck2shine/BRFluentModule"

Swift 包管理器

手动安装

只需将文件 BRFluentModule.swift 复制到您的项目中,即可使用。

使用方法

创建对象,在要写入流畅界面的对象后面添加 后缀运算符 ^+ ,最后以 后缀运算符 ^- 结束,以避免使用警告。

    let button = UIButton()
    button^+
        .frame(CGRect(x: 100, y: 100, width: 100, height: 40))
        .backgroundColor(.red)
        .alpha(0.8)^-

或者

    let someView =
        UIView()^+
        .frame(CGRect(x: 10, y: 20, width: 300, height: 400))
        .isHidden(true)
        .backgroundColor(.blue)^-

    someView.layer^+
        .borderWidth(3)
        .borderColor(UIColor.gray.cgColor)
        .cornerRadius(5)^-