KeyHolder
记录macOS的快捷键,类似于 Alfred 应用。
使用
CocoaPods
pod 'KeyHolder'
卡特哈吉
github "Clipy/KeyHolder"
github "Clipy/Magnet"
github "Clipy/Sauce"
示例
设置默认快捷键组合。
let recordView = RecordView(frame: CGRect.zero)
recordView.tintColor = NSColor(red: 0.164, green: 0.517, blue: 0.823, alpha: 1)
let keyCombo = KeyCombo(doubledModifiers: .command)
recordView.keyCombo = keyCombo
一些代理方法
func recordViewShouldBeginRecording(_ recordView: RecordView) -> Bool
func recordView(_ recordView: RecordView, canRecordShortcut keyCombo: KeyCombo) -> Bool
func recordView(_ recordView: RecordView, didChangeKeyCombo keyCombo: KeyCombo?)
func recordViewDidEndRecording(_ recordView: RecordView)
或者您可以使用闭包。
let recordView = RecordView(frame: CGRect.zero)
recordView.didChange = { keyCombo in
guard let keyCombo = keyCombo else { return } // Clear shortcut
// Changed new shortcut
}
依赖关系
源代码依赖于热键库。
如何构建
- 移动到项目根目录
- 使用
carthage
或git submodule
安装依赖库 carthage checkout --use-submodules
或git submodule update --init --recursive
- 在 Xcode 中打开
KeyHolder.xcworkspace
- 构建