Joe
Joe

Reputation: 659

How to make UISlider thicker?

I want to create a really thick horizontally oriented UISlider. I know it is easy to make it longer, but how do I make the track (and therefore the area in which touch events can be registered) thicker?

Upvotes: 2

Views: 3746

Answers (2)

Daniel Storm
Daniel Storm

Reputation: 18878

Swift equivalent of Michael's answer:

import UIKit

class ThickSlider: UISlider {

    override func trackRect(forBounds bounds: CGRect) -> CGRect {
        return bounds
    }

}

Upvotes: 1

Michael Dautermann
Michael Dautermann

Reputation: 89509

Subclass the UISlider and then make this modification:

- (CGRect)trackRectForBounds:(CGRect)bounds
{
    return bounds;
}

(I just tried this out in UICatalog -- which is a very nice set of Apple sample code -- and it works perfectly great).

Upvotes: 9

Related Questions