| 测试已测试 | ✓ |
| 语言语言 | SwiftSwift |
| 许可 | MIT |
| 发布上次发布 | 2016年12月 |
| SwiftSwift 版本 | 3.0 |
| SPM支持 SPM | ✗ |
由Christoffer Winterkvist,Vadym Markov维护。
Brick适用于基本和复杂场景的通用视图模型。为基本表格视图单元格映射就像做饼一样简单,如果您有更多属性,您可以使用meta字典添加可能需要的所有附加属性。它还支持关系,这样您可以在视图模型内部嵌套视图模型。
public struct Item: Mappable {
public var index = 0
public var title = ""
public var subtitle = ""
public var text = ""
public var image = ""
public var kind = ""
public var action: String?
public var size = CGSize(width: 0, height: 0)
public var meta = [String : AnyObject]()
}UITableViewCell中它通常用于textLabel.text,但您可以自由地按需使用它。UITableViewCell中它通常用于detailTextLabel.text。Item的较长文本。UITableViewCell或UICollectionViewCell的reuseIdentifier。UITableViewCell/UICollectionViewCell继承,或者通过视图中手动设置的高度计算进行设置。let item = Item(
title: "John Hyperseed",
subtitle: "Build machine",
meta: [
"operatingSystem" : "OS X",
"xcodeVersion" : 7.3
])
print(item.meta("operatingSystem", "")) // prints "OS X"
print(item.meta("xcodeVersion", 0.0)) // prints 7.3
Brick可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中。
pod 'Brick'Brick也可通过Carthage获取。要将它写入您的Cartfile中。
github "hyperoslo/Brick"Hyper Interaktiv AS, [email protected]
我们非常希望您为 Brick 贡献,请查看 CONTRIBUTING 文件获取更多信息。
Brick 采用 MIT 授权协议。更多信息请查看 LICENSE 文件。