Reset Constant constant NSLayoutConstraint with its original value from storyboard
Imagine a script you posted UIView
with NSLayoutConstraint
that has different constant
sizes for several classes in your storyboard. Now you want to animate the position of this view by changing this constraint constant
. Let's say you want to animate it from -100 to its original value that you set in the storyboard for the current size class. How can you get this value for use in your animation code?
This way, you won't have to define the size class in code and set it programmatically with values ββthat match what was already set in the storyboard.
source to share
Plug the layout constraint into an outlet in Interface Builder. Then, when your view is loaded, cache the value constraint.constant
in the ivar. Then you can change it and reset it however you like.
source to share