ios - Swift 3D Touch Force Value in UIButton -
how can measure 3d touch force applied uibutton function? want use changing volume of avaudioplayer property in swift.
you can use recognizes 3d touch uiview classes \ subclass
make custom class
class custombutton : uibutton{ override func touchesmoved(touches: set<uitouch>, withevent event: uievent?) { touch in touches{ print("% touch pressure: \(touch.force/touch.maximumpossibleforce)"); } } override func touchesended(touches: set<uitouch>, withevent event: uievent?) { print("touches end") } } and instead of uibutton touch observer (touchupinside \ touchupinside..) use methods above
work uiview class
class customview : uiview ....//same code above
Comments
Post a Comment