まぁ、普通に以下のようにAnimationのコードを書いていたりすると思うのですが、以下のようにしていたらハマりました。
hoge.swift
self.hogeButtonBottomConstraint.constant = 8
UIView.animate(withDuration: 0.2) {
self.view.layoutIfNeeded()
}
何がまずいかっていうと、self.view.layoutIfNeeded()をAnimationさせる前に叩いていないので、以下の処理が呼ばれる前にConstraintを設定すると全部Animationされてしまうんですよね。
なので、以下のようにAnimaitonしたいConstraintの修正のみをself.view.layoutIfNeeded()
ではさんであげる必要があります。
hoge.swift
// ここに以下のような処理があると一緒にAnimationされちゃう
// self.fugaButtonBottomConstraint.constant = 8
self.view.layoutIfNeeded()
self.hogeButtonBottomConstraint.constant = 8
UIView.animate(withDuration: 0.2) {
self.view.layoutIfNeeded()
}
まぁ、皆さんはご存知だとは思うんですけどね...