如何测量应用于UIButton函数的三维触摸力?我想用它来改变AVAudioPlayer属性的体积。
发布于 2016-02-06 11:43:32
您可以对所有UIView类\子类使用识别3D触摸的东西。
创建一个自定义类
class customButton : UIButton{
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches{
print("% Touch pressure: \(touch.force/touch.maximumPossibleForce)");
}
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("Touches End")
}
}而不是UIButton Touch Observer (TouchUpInside \ TouchUpInside..),只需使用上面的方法
这将适用于所有UIView类。
class customView : UIView ....//same code as abovehttps://stackoverflow.com/questions/35238278
复制相似问题