ForceTouchGestureRecognizerSwift 0.3

ForceTouchGestureRecognizerSwift 0.3

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2015年10月
SPM支持 SPM

Ashley Mills 维护。



  • Ashley Mills

ForceTouchGestureRecognizer.swift

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