我正在尝试使用制作自定义滑块
class MySlider: UISlider {
override func trackRect(forBounds bounds: CGRect) -> CGRect {
let customBounds = CGRect(origin: bounds.origin, size: CGSize(width: bounds.size.width, height: 5.0))
super.trackRect(forBounds: customBounds)
return customBounds
}
}
答案 0 :(得分:0)
我无需子类即可实现此目标
通过IB设置缩略图色调:Default
@IBOutlet weak var slider: MySlider!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let size = CGSize(width: 1 , height: 1)
UIGraphicsBeginImageContext(size)
let finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
slider.setThumbImage(finalImage, for: .normal)
}