Search code examples
iosswiftuislider

How to make custom curvy UISlider?


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


Solution

  • 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