If you're using storyboards and constraints, one clever way that I've found is to set the width or height constraint of the disappearing view to 0.
As an example:

@IBAction func onTapSquare(_ sender: Any) {
let constraint = disappearingView.constraintForIdentifier(id: "example_width")
constraint?.constant = 0
}
Note that you have to write the constraintForIdentifier
function yourself, you can copy/paste from my view extension here:
Github link!
I whipped up a tiny example project which you can grab here:
Disappearing Constraint Example
If you've got margin in between the views, you can set that to 0 with a similar method. Good luck!
Here it is in action:
