问题
I'm trying to make custom slider using
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
}
}
Updated thumb/max/min tint colour from storyboard
The problem is need to remove min and max space from both ends as shown in pics. How i can do that?
回答1:
I was able to achieve this without subclassing:
Set Thumb Tint: Default
through IB
@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)
}
来源:https://stackoverflow.com/questions/52987375/ios-custom-slider-remove-min-and-max-space-from-both-ends