测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2015年10月 |
SPM支持 SPM | ✗ |
由 Ashley Mills 维护。
UIGestureRecognizer Swift 子类,启用 3D Touch
只需将 ForceTouchGestureRecognizer.swift 文件拖放到您的项目中即可。就这么简单!
override func viewDidLoad() {
super.viewDidLoad()
let forceTouchGesture = ForceTouchGestureRecognizer(target: self, action: "pressView:")
forceTouchGesture.minimumValue = 0.1 // Minimum force value before touch is recognised
forceTouchGesture.tolerance = 0.2 // Allows the pressure to be lifted slightly without the gesture ending
view.addGestureRecognizer(forceTouchGesture)
}
func pressView(gesture: ForceTouchGestureRecognizer) {
print("force: \(gesture.forceValue)") // forceVouch is CGFloat between 0 & 1
}
遇到错误或者有新功能吗?创建一个 pull request 去实现它吧!
干杯,Ash