iPhone : How to detect the end of slider drag?

后端 未结 16 2672
不思量自难忘°
不思量自难忘° 2020-12-02 07:36

How to detect the event when the user has ended the drag of a slider pointer?

16条回答
  •  猫巷女王i
    2020-12-02 08:38

    In Swift 4 you can use this function

    1 Frist step:- Adding the target in slider

    self.distanceSlider.addTarget(self, action: #selector(self.sliderDidEndSliding(notification:)), for: ([.touchUpInside,.touchUpOutside]))
    

    2 Second step:- Create a function

    @objc func sliderDidEndSliding(notification: NSNotification)
    {
       print("Hello-->\(distanceSlider.value)")
    }
    

提交回复
热议问题