开发者

UISlider, knowing thumbImage position [duplicate]

开发者 https://www.devze.com 2022-12-21 06:11 出处:网络
This question already has answers here: 开发者_如何学编程 How to get the center of the thumb image of UISlider
This question already has answers here: 开发者_如何学编程 How to get the center of the thumb image of UISlider (12 answers) Closed 9 years ago.

Is there a way to display the Slider value over the ThumbImage?

I was thinking of getting the X position of the ThumbImage and then moving a UILabel accordingly.

Is that possible?


Unfortunately, you have to do this yourself. I did something like it for shakedown. As you can see there, I put a UILabel above the slider so that the user could see as they manipulated.

Luckily, it's pretty easy to do. Simply send the slider a message like addTarget:action:forControlEvents:, with a method you create as the "action" parameter. This method will then get called whenever the thumb is moved (depending on your forControlEvents value). Inside of that method, check the UISlider's value property and update the UILabel accordingly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号