开发者

UISlider, knowing thumbImage position [duplicate]

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜