简体   繁体   中英

Remove UISlider Knob or change image swift

I've added a UISlider to the view. I was wondering whether it is possible to remove the knob or just change the image in swift? How can i do this?

滑块旋钮称为拇指图像,您可以使用setThumbImage:forState:方法更改它

mySlider.setThumbImage(nil, forState: UIControlState.Normal) // Remove the knob image by setting it to nil, or add your own image.

For Swift 5.0 or Later Version

for state: UIControl.State in [.normal, .selected, .application, .reserved] {
            editorSlider.setThumbImage(UIImage.init(named: "slider_thumb"), for: state)
        }

Change the thumb tint to clear colour from storyboard

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM