In storyboard have a UIView, with a constraint for example "0.1" proportional height.
Imagine you have a similar constraint "0.1", on views in many different scenes.
Say you want to change the value 0.1 to 0.975.
You have to change it individually everywhere.
Is there some way to make a sort of "global value", using @IBInspectable and/or constraints?
So that you can change them all at once, and see the results all at once in storyboard.
(Of course, at run-time you could propagate these in code. But it's better to see it on storyboard.)
Note for example that Wain's solution below works perfectly: you can set the value once, and affect everywhere in the app. But unfortunately it only does that at run time, you don't see it on storyboard.
I haven't tried it, and this is just typed in here so excuse typos, but I would consider creating an extension on NSLayoutConstraint
, something along the lines of:
let constants = [
"bannerHeight" : CGFloat(50)
]
extension NSLayoutConstraint {
func setCommonConstant(name: String) {
self.constant = constants[name]!
}
}
and then using the user defined runtime attributes in Xcode so specify the name to use:
commonConstant, type String, value name
So, like this, on each Constraint anywhere in the storyboard:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With