Say you want to animate a frame change, and you are using SnapKit. You can use the remakeConstraints function to set the new constraints, and then in an animation block call layoutIfNeeded() on the superview.

func setPurpleViewVisible(_ visible: Bool) {
    self.purpleView.snp.remakeConstraints { make in

        if visible {
        } else {
    UIView.animate(withDuration: 0.3, animations: {

Sometimes it helps to make a container view so that layoutIfNeeded() can be called on that, ensuring other parts of the superview do not animate.