이수현
이수현

Reputation: 1

how to customize Thumb circle in StepSlider?

I've been using https://github.com/spromicky/StepSlider.git -> stepslider library. But I am having trouble adjusting the position of the thumb. I want the bottom of the thumb to be aligned with the track like the picture above. My current code is ...

let testSlider: StepSlider = {
    let t = StepSlider()
    t.index = 2
    t.maxCount = 5
    t.tintColor = AppColor.purple30

    if let image = UIImage(named: "thumbImage") {
        let resizedImage = image.resized(to: CGSize(width: 27, height: 62))
        t.sliderCircleImage = resizedImage
    }
    
    t.sliderCircleRadius = 31
    return t
}()
extension UIImage {
    func resized(to size: CGSize) -> UIImage {
        UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
        self.draw(in: CGRect(origin: .zero, size: size))
        let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return resizedImage ?? self
    }
}

Please let me know enter image description here

I tried to make custom StepSlider but didn't work. I resized the image myself and saved it in the asset, but it was not very clean, so I’m asking.

Upvotes: -1

Views: 29

Answers (0)

Related Questions