好吧,我看了你标记的答案,并在操场上为你做了些什么。不确定它是否适合您的情况,但关键是要研究UISlider
的方法,你可以覆盖here
import UIKit
class SomeController: UIViewController {
let slider = MyCustomSlider()
//etc...
}
class MyCustomSlider: UISlider {
override func maximumValueImageRect(forBounds bounds: CGRect) -> CGRect {
var r = super.maximumValueImageRect(forBounds: bounds)
r.origin.x -= 3
return r
}
}