在应用程序模态浮动窗口中显示内容,用户可以通过键入进行模糊筛选。其样式大致与浮动的 Spotlight 窗口匹配。
该列表使用默认的 NSTableView
样式,因此在 Big Sur 和更早版本的 macOS 上看起来都很协调!
此模块致力于尽可能地管理其组件的内存。这意味着您无需保留对窗口或其控制器的引用。操作完成后,两者都将被释放。
如果您想筛选例如“最近使用的文件”之类的有限文件集合,或显示已知宏的列表,这将非常有用。
import FloatingFilter
// ...
let items = [
Item(identifier: UUID(), title: "Create new widget"),
Item(identifier: 202002200930, title: "Open last document"),
Item(identifier: "custom-ID_123", title: "Show downloaded data")
]
FloatingFilterModule.showFilterWindow(items: items) { selectedItems in
print("Selected:", selectedItems.map { $0.title })
}
添加到您的 Cartfile
github "cleancocoa/FloatingFilter"
然后运行
$ carthage update
...并在您的应用程序中包含 Carthage/Build/Mac
中的 FloatingFilter.framework
。
版权所有 (c) 2020 Christian Tietze。根据 MIT 许可证分发。
模糊匹配的版权所有 (c) 2015 Yichi Zhang https://github.com/yichizhang/SwiftyStringScore