首页 > 解决方案 > 子类化 UISlider 以使用 IBDesignable/IBInspectable 自定义拇指图像?

问题描述

我正在使用此代码来自定义我的 UISlider 的 thumbImage。它在情节提要中正确构建,但是当我构建和运行时它不显示我的图像?可能是因为我也把它作为插座连接了吗?(必要,因为我需要在代码中设置滑块的值)

@IBDesignable
class DesignableSlider: UISlider {



    @IBInspectable var thumbImage: UIImage? {
        didSet{
              setThumbImage(thumbImage, for: .normal)
        }
    }


}

标签: iosswiftuislideribdesignableibinspectable

解决方案


推荐阅读