I'm trying to scale constraints' values just after setting them up in a such way:
@IBDesignable
class ScaledConstraint: NSLayoutConstraint {
@IBInspectable var constantValue: CGFloat = 0 { didSet { constantValueDidSet() } }
func constantValueDidSet() {
super.constant = (constantValue / 320) * UIScreen.main.bounds.width
}
}
But that approach is forcing me to change IBInspectable variable for every constraint. I've tried to deal with it overriding default constant value but it works only when I set constant value from the code, and deals no effect when I'm setting it from the interface builder:
override var constant: CGFloat {
set(newValue) {
self.constant = (newValue / 320) * UIScreen.main.bounds.width
}
get {
return self.constant
}
}
Is there a way to change constant value just after setting it from the interface builder without custom IBInspectable variable? Thanks in advance!