我是UIStepper
的子类,我想应用一些自定义样式。我正在使用以下方法...
func setupStepper() {
let incrementImageFromFile : UIImage = UIImage(named: "plusSymbol")!
let incrementImage : UIImage = incrementImageFromFile.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
let decrementImageFromFile : UIImage = UIImage(named: "minusSymbol")!
let decrementImage : UIImage = decrementImageFromFile.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
tintColor = UIColor.clear()
setDecrementImage(decrementImage, for: [])
setIncrementImage(incrementImage, for: [])
}
我尝试将此样式挂钩到以下方法中,但不会调用它。
class RoundedStepper: UIStepper {
override init(frame: CGRect) {
super.init(frame: frame)
setupStepper()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupStepper()
}
override func awakeFromNib() {
setupStepper()
}
…
我在Storyboard中使用这个自定义步进子类。为什么setupStepper()
没有被调用?添加此样式方法的正确位置在哪里?