To search for all subzones from your view, you can use this code:
for subview in self.view.subviews {
But to use it, you must determine what you need. You can mark any item that you create with a special identifier:
myButton.restorationIdentifier = "mySpecialButton";
And after that you can find that your element uses this structure:
for view in view.subviews { if (view.restorationIdentifier == "mySpecialButton") { print("I FIND IT"); view.removeFromSuperview(); } }
:)
source share