FreestylerCore 1.0.1

FreestylerCore 1.0.1

测试已测试
语言 SwiftSwift
许可证 MIT
发布最后发布2016年11月
SwiftSwift 版本3.0
SPM支持 SPM

Alexander Doloz 维护。



  • Alexander Doloz

什么是它?

当我们从设计师的草图中开发应用程序时,我们经常一遍又一遍地遇到相同的视觉模式 - 颜色、字体等。将它们保存在应用程序代码的一个地方并在每个地方重用是一个明智的决定。这正是 FreestylerCore 助您做到的。

FreestylerCore定义了一个名为 Style 的类别。可以将多个 Style 合并成一个。参见用法部分了解如何创建您自己的样式并应用它们。

FreestylerCore是更大框架的一部分 - FreestylerFreestyler = FreestylerCore + 大量样式。目前它正在积极开发中,欢迎贡献力量。

要求

  • iOS 8.0+
  • Swift 3
  • Xcode 8.0+

安装

手动

  1. 克隆或下载 FreestylerCore
  2. Source 文件夹拖动到 Xcode 中的项目;确保已选中☑️ 将项目复制到目标分组文件夹(如果需要)

用法

这里是基本用法,更多示例请参见 Playground。

  • 创建样式
let roundCorners = Style("Round corners") {
    (view: UIView) in
    view.layer.cornerRadius = 5.0
}
let redBorder = Style("Red Border") {
    (view: UIView) in
    view.layer.borderColor = UIColor.red.CGColor
}
  • 应用样式
button <~ roundCorners <~ redBorder
// --- or ---
button <~ [roundCorners, redBorder]

// You can combine multiple styles into one 
let style = roundCorners <~ redBorder
button <~ style

// You can apply style to multiple items at once
[button, label, imageView] <~ style

// And multiple styles to multiple labels too
[button, label, imageView] <~ [roundCorners, redBorder]

如果您不喜欢使用自定义运算符,有相应的方法

button.apply(style: roundCorners).apply(style: redBorder)
// --- or ---
button.apply(styles: [roundCorners, redBorder])

// You can instantiate style from array literal
let style: Style = [roundCorners, redBorder]
button.apply(style: style)

// You can apply style to multiple items at once
[button, label, imageView].apply(style: style)

// And multiple styles to multiple labels too
[button, label, imageView].apply(styles: [roundCorners, redBorder])

目标

  • 添加所有运算符和方法的单元测试。
  • 添加对其他平台的支援,特别是对 macOS。
  • 添加对Swift Package Manager的支持。

作者

Alexander Doloz,[email protected]

许可证

FreestylerCore 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE.txt 文件。