MengTo / Spring

A library to simplify iOS animations in Swift.
http://designcode.io
MIT License
14.08k stars 1.8k forks source link

How to use with turning on/off constraints #310

Open imagemason opened 6 years ago

imagemason commented 6 years ago

So I've got some views that I want to move around in response to user interaction. To position them I have multiple constraints with different priorities - I can turn one or more constraints off and since there are still other constraints available the view (or whatever) moves to the new location. So normally I would do something like this:

self.settingsBottomConstraint.isActive = false UIView.animate(withDuration: 0.5, delay: 0, options: [.curveEaseInOut], animations: { self.brainView.layoutIfNeeded() }, completion: nil)

How can I accomplish that using Spring? I've tried everything I can think of - it doesn't animate, just turns off the constraint without animation.

Two no good least weird looking things I've tried that doesn't work (I've tried many more):

self.settingsBottomConstraint.isActive = false self.brainView.animateNext {
self.brainView.layoutIfNeeded() }

or

self.brainView.animateNext {
self.settingsBottomConstraint.isActive = false }

Help?! Surely I'm just doing it wrong?