How to make custom curvy UISlider?
Asked Answered
S

1

7

I want to create custom curvy UISlider as like below screen which is fit to screen.

enter image description here

I checked MTCircularSlider library and also apply of tranform animaton to UISlider control but none of them working. My mind got stuck after performing many tries.

Thank you

Sharecrop answered 25/1, 2018 at 6:51 Comment(11)
what problem are you facing with MTCircularSlider ?Kathrinekathryn
It will not expand the slider in full screenSharecrop
i think you could create MTCircularSlider in different size. Is it possible? If so, try to create with Screen size & customize the libraryKathrinekathryn
Yes i already tried to customize but can't getting idea from where should i have to change the codeSharecrop
From what I quickly read of the doc: Use trackMinAngle() and trackMaxAngle(). seems to be what you need. Set the slider as "big", find the angle corresponding of when the slider touch the borders of you view (screen in your case).Valleau
@Valleau What do you mean by Set the slider as "big"?Sharecrop
"as like below screen which is fit to screen." Could you be more specific? Do you mean that you see all the slider (circle) on the screen, or that some part is hidden?Valleau
@Valleau As you can see in screen, I want to display as semi circle which is fit to screen widthSharecrop
So you need to set a frame for your MTCircularSlider with bigger width that your screen width. Is that your issue?Valleau
@Valleau yes, ExactlySharecrop
Let us continue this discussion in chat.Valleau
C
2

Using MTCircularSlider library

fileprivate var controlRadius: CGFloat {
     return min(bounds.width, bounds.height) / 2.0 - controlThickness
 }

See above this library uses min value from width and height.

So, You need to maintain your view width, because it's depend on minimum value of View. You can mange your view by leading and trailing according below screenshotenter image description here

or either you can use by proportionalWidth constrain to 0.80 of your superview

And also set the trackAngle as below

enter image description here

Corfu answered 30/1, 2018 at 6:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.