iPhone:Programming UISlider to position at clicked location

后端 未结 6 464
北荒
北荒 2020-12-09 13:59

How to set the slider to clicked position and get the slider value on the clicked location on UISlider in iPhone programming. i know we can drag the slider to that position

6条回答
  •  眼角桃花
    2020-12-09 14:37

    It seems like just subclassing UISlider and returning always true to the beginTracking produce the desired effect.

    iOS 10 and Swift 3

    class CustomSlider: UISlider {
        override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
            return true
        }
    }
    

提交回复
热议问题