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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -