WorldDownTown / RangeSeekSlider

RangeSeedSlider provides a customizable range slider like a UISlider.
MIT License
755 stars 282 forks source link

Change label position #93

Open pt9dat opened 4 years ago

pt9dat commented 4 years ago

Issue Description

Hi, can I change the label position from bottom to top?

Environment

Franknxtn commented 4 years ago

I'm also facing the same problem, all the examples have labels at top but i have at bottom and there is no way other than setting the label padding to a negative value. wish there was a more straightforward way to place label on top of slider.

SteveChina commented 4 years ago

+1

AngCosmin commented 4 years ago

I was able to do it by setting the Label padding property to a negative value. For example, I used -60

jigneshradadiya commented 4 years ago

I'm also facing the same problem, all the examples have labels at top but i have at bottom and there is no way other than setting the label padding to a negative value. wish there was a more straightforward way to place label on top of slider.

I got the solution for this issue. Just update below code in RangeSeekSlider.swift file

/ Old code let newMinLabelCenter: CGPoint = CGPoint(x: leftHandle.frame.midX, y: leftHandle.frame.maxY + (minLabelTextSize.height/2) + labelPadding) let newMaxLabelCenter: CGPoint = CGPoint(x: rightHandle.frame.midX, y: rightHandle.frame.maxY + (maxLabelTextSize.height/2) + labelPadding)/ //Try this // Updated code to set labels above the handle let YPossitionMin=leftHandle.frame.midY - (minLabelTextSize.height + labelPadding) let YPossitionMax=rightHandle.frame.midY - (maxLabelTextSize.height + labelPadding) let newMinLabelCenter: CGPoint = CGPoint(x: leftHandle.frame.midX, y: YPossitionMin) let newMaxLabelCenter: CGPoint = CGPoint(x: rightHandle.frame.midX, y:YPossitionMax)