Simulator Screen Shot - iPhone 11 Pro Max - 2019-12-16 at 14.52.33.png
DispatchQueue.main.async {
let view = UIView()
view.frame = viewSlider.frame
let layer = CALayer()
layer.frame = CGRect(x: 0, y: viewSlider.frame.size.height * 0.26, width: 2, height: viewSlider.frame.size.height * 0.25)
layer.backgroundColor = color.cgColor
let layerReplicator = CAReplicatorLayer()
layerReplicator.frame = viewSlider.bounds
view.layer.addSublayer(layerReplicator)
layerReplicator.addSublayer(layer)
layerReplicator.instanceCount = Int(viewSlider.maximumValue) + 1
let width = viewSlider.frame.size.width - 2
let space = width / CGFloat(viewSlider.maximumValue)
layerReplicator.instanceTransform = CATransform3DMakeTranslation(space, 0, 0);
viewSlider.superview!.insertSubview(view, at: 0)
}
- 不是直接給UISlider添加CALayer是防止復(fù)制圖層蓋住thumb
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者