gpt4 book ai didi

ios - 自定义UISlider拇指图标: How to stop thumb icon from reverting back to default circle icon when drag?

转载 作者:行者123 更新时间:2023-11-29 01:23:17 25 4
gpt4 key购买 nike

我想将我的 UISlider 的拇指自定义为我制作的矩形图标。我已经设法做到了这一点。问题是当我拖动 UISlider 时它变回默认的圆形图标。

如何设置缩略图使其始终保持为自定义矩形图标,即使在我拖动它时也是如此?

我详细介绍了我的代码并包含了一个链接,这样您就可以在下面看到我在说什么。

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

最佳答案

我只需要删除行 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)
}
}

关于ios - 自定义UISlider拇指图标: How to stop thumb icon from reverting back to default circle icon when drag?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34345867/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com