0
我定製了UI按鈕並使用IBInspectable創建了一些屬性。但是,我還需要爲選定或突出顯示的狀態使用相同的屬性,並且可以在Interface Builder中對其進行檢查。我想知道它是否可以實現?IB定製UIButton時不同狀態的屬性
這裏是定製的按鈕,我創建
@IBDesignable
class ImageLabelButton: UIButton{
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/
let buttonImgView = UIImageView()
let buttonLabel = UILabel()
// let stackView = UIStackView()
// Override property observors
@IBInspectable
var textColor:UIColor? {
get {
return buttonLabel.textColor
}
set(newValue) {
self.buttonLabel.textColor = newValue
}
}
}
我想爲其他狀態的IBInspectable屬性爲好。可以做到嗎?謝謝!
添加兩個新的可檢查屬性? :) – Cristik