In fact, I was looking for an example of a drop-down button. But unfortunately it turned out to be not fully working, and I do not know well how dynamic constraints and anchors work. Therefore I ask for your help.
'NSGenericException', reason: 'Unable to activate constraint with
anchors and because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.
You can find my source code on Github: https://github.com/Archetapp/Drop-Down-Menu/blob/master/sdafjkbslib/ViewController.swift
I found similar problems and their solution was:
Check whether you added the programmatically created view to its parent before activating constraints.
Check whether you write constraints activation code inside viewDidLoad () / viewWillAppear (). You should write constraints in the updateViewConstraints or viewWillLayoutSubviews.
Check whether you turn off translatesAutoresizingMaskIntoConstraints.
But it did not help me.