如何使用滑块值和与滑块拇指相同的位置运行气泡(在滑块顶部)?
我有一个最小值 = 0 且最大值 = 1000 的滑块。滑块上有一个气泡,它与滑块的拇指一起运行并显示滑块的值。 但我无法用滑块拇指运行气泡。 这是代码片段:
CGFloat sliderMax = localSlider.maximumValue;
CGFloat sliderMin = localSlider.minimumValue;
CGFloat sliderMaxMinDiff = sliderMax - sliderMin;
CGFloat sliderValue = _dsp;
CGFloat halfMax = (sliderMax+sliderMin)/2.0;
//int hMax = [halfMax intValue];
CGFloat xCoord = halfMax- 55.0;
CGFloat yCoord = (CGFloat)_positionX;
if (sliderValue > halfMax)
{
xCoord = xCoord-(sliderValue-halfMax);
}
else
{
xCoord = xCoord + (halfMax-sliderValue);
}
xCoord= xCoord + (642/sliderMaxMinDiff)*(sliderValue-sliderMin);
newB.frame = CGRectMake(xCoord,yCoord,84,47);
I have a slider with the minValue = 0 and maximumValue = 1000. I have a bubble on slider which runs with the thumb of the slider and displays the value of the slider.
But i am unable to run the bubble with the slider thumb.
Here's the code snippet:
CGFloat sliderMax = localSlider.maximumValue;
CGFloat sliderMin = localSlider.minimumValue;
CGFloat sliderMaxMinDiff = sliderMax - sliderMin;
CGFloat sliderValue = _dsp;
CGFloat halfMax = (sliderMax+sliderMin)/2.0;
//int hMax = [halfMax intValue];
CGFloat xCoord = halfMax- 55.0;
CGFloat yCoord = (CGFloat)_positionX;
if (sliderValue > halfMax)
{
xCoord = xCoord-(sliderValue-halfMax);
}
else
{
xCoord = xCoord + (halfMax-sliderValue);
}
xCoord= xCoord + (642/sliderMaxMinDiff)*(sliderValue-sliderMin);
newB.frame = CGRectMake(xCoord,yCoord,84,47);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Ashutosh它可能有一些用处
你也可以从 https://github.com/elc/ELCSlider 获取一些提示
这是我制作的屏幕截图
我使用这些值添加了滑块-
@Ashutosh It might be of some use
You can also take some hint from https://github.com/elc/ELCSlider
Here is a screen shot of what i made
I added the slider using these values-