Reputation: 4166
I want to customize the thumb of my UISlider to a rectangular icon I made. I've managed to do that somewhat. The problem is when I drag the UISlider it changes back to the default circle icon.
How can I set the thumb image so it always remains as the custom rectangular icon even when I drag it?
I've detailed my code and included a link so you can see what I'm talking about below.
class DrawViewController: UIViewController {
var heightSlider: UISlider = UISlider()
var fontColor: UIColor = UIColor(red:0.91, green:0.91, blue:0.91, alpha:1.0)
var barButtonColor: UIColor = UIColor(red:0.03, green:0.25, blue:0.51, alpha:1.0)
override func viewDidLoad() {
super.viewDidLoad()
heightSlider = UISlider(frame: CGRectMake(0, 20, 98, 31))
heightSlider.minimumTrackTintColor = barButtonColor
heightSlider.maximumTrackTintColor = fontColor
heightSlider.thumbTintColor = barButtonColor
heightSlider.setThumbImage(UIImage(named: "blueSliderThumbHeight")!, forState: .Normal)
self.view.addSubview(heightSlider)
}
}
To see my app/what I'm talking about
Upvotes: 0
Views: 1572
Reputation: 4166
I just have to delete the line heightSlider.thumbTintColor = barButtonColor
class DrawViewController: UIViewController {
var heightSlider: UISlider = UISlider()
var fontColor: UIColor = UIColor(red:0.91, green:0.91, blue:0.91, alpha:1.0)
var barButtonColor: UIColor = UIColor(red:0.03, green:0.25, blue:0.51, alpha:1.0)
override func viewDidLoad() {
super.viewDidLoad()
heightSlider = UISlider(frame: CGRectMake(0, 20, 98, 31))
heightSlider.minimumTrackTintColor = barButtonColor
heightSlider.maximumTrackTintColor = fontColor
heightSlider.thumbTintColor = barButtonColor //delete this line!
heightSlider.setThumbImage(UIImage(named: "blueSliderThumbHeight")!, forState: .Normal)
self.view.addSubview(heightSlider)
}
}
Upvotes: 1