gpt4 book ai didi

iOS 自定义 slider 删除两端的最小和最大空间

转载 作者:行者123 更新时间:2023-11-30 11:03:41 25 4
gpt4 key购买 nike

我正在尝试使用自定义 slider

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
}
}

更新了 Storyboard 中的拇指/最大/最小色调颜色 enter image description here

问题是需要从两端删除最小和最大空间,如图所示。我怎样才能做到这一点? enter image description here enter image description here

最佳答案

我无需子类化即可实现此目的:

通过 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)
}

关于iOS 自定义 slider 删除两端的最小和最大空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52987375/

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