this is my code
@IBDesignable class BarPopView: UIView {
@IBInspectable var ft: NSString = "1"
@IBInspectable var ffPrompt: NSString = "Area"
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
func setupView() {
print("text: \(ft), prompt: \(ffPrompt)")
}
}
and i set these value in interface builder
ft: 50
ffPrompt: "Change"
but result is print
"text: 1, prompt: Area"
Its because the method setupView
is called during initialisation and during that the properties have initial values.
If you want to tweak them accordingly , use property observers:
@IBInspectable var ft: String = ""{
didSet {
setupView()
}
}