OSXTableKit 0.1.5

OSXTableKit 0.1.5

GDXRepo 维护。



OSXTableKit

Swift 4.2 compatible CocoaPods compatible Platform OS X License: MIT

NSTableView 的包装器,用于管理单列表格。支持 macOS 10.10 或更高版本。

启发于 https://github.com/maxsokolov/TableKit/

概述

这个库可以帮助您在代码中管理类似 iOS 的表格。没有 XIB,没有故事板,没有痛苦。只有纯代码。创建表格的简单示例

...
tableView.backgroundColor = .darkGray
let director = TableDirector(with: tableView)
director.clear()
let sections = [ // some sections with rows arrays inside
    [0, 1, 2, 3].map { "Row \($0)" },
    [0, 1, 2, 3, 4, 5].map { "Row \($0)" },
    [0, 1].map { "Row \($0)" }
]
// fill the table
for (i, item) in sections.enumerated() {
    let view = SampleTableHeaderView()
    view.title = "Section \(i)"
    let section = TableSection(headerView: view)
    for subitem in item {
        section += TableRow<SampleTableCell>(with: subitem).on(.click) {
            print("clicked \($0.cell!)")
        }
    }
    director += section
}
director.reload()

安装

可以通过 CocoaPods(或者当然是由手动将源代码文件拖放到您的项目中)安装。

CocoaPods

OSXTableKit 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 中:

pod 'OSXTableKit'

然后在终端中运行以下命令:

$ pod install

讨论

优点

  • 显示类似于iOS的单列样式表格视图。
  • 支持非固定部分。
  • 严格类型的表格部分、行和操作。完全安全的表格结构编码。
  • 自动计算部分和行的高度。

不支持的内容?

  • 固定部分。
  • 带有空标题的部分。解决方案:创建一个高度等于1且背景颜色与表格视图背景颜色相同的视图。
  • 类似于macOS原生表格视图的多列。
  • 目前只支持clickselectdeselect表格操作。可能以后还会添加其他操作。

许可证

MIT