swift 3.0 UISlider留下拇指

时间:2018-02-23 02:48:32

标签: swift uislider

这段代码,

slider = UISlider(frame: CGRect(x: 80,y: 9.5,width: UIScreen.main.bounds.width - 160,height: 15))
slider.minimumTrackTintColor = UIColor.orange
slider.isContinuous = false
slider.addTarget(self, action: #selector(pageChange), for: .valueChanged)
slider.setThumbImage(UIImage(named:"RM_3"), for: .normal)
bottomBar?.addSubview(slider)

如何清理左拇指???

slider

1 个答案:

答案 0 :(得分:0)

在Swift 3.0中

import UIKit


class DBSlider: UISlider {

    @IBInspectable var thumbImage: UIImage?
    @IBInspectable var minTrackColor:UIColor?
    @IBInspectable var maxTrackColor:UIColor?


    // MARK: Lifecycle

    override func awakeFromNib() {
        super.awakeFromNib()

        if let thumbImage = thumbImage
        {0
            self.setThumbImage(thumbImage, for: .normal)
        }
        if let minTrackColor = minTrackColor
        {
            self.minimumTrackTintColor = minTrackColor
        }
        if let maxTrackColor = maxTrackColor
        {
            self.maximumTrackTintColor = maxTrackColor
        }

    }
}

enter image description here enter image description here enter image description here