'How can I move a popup on the screen programatically (ios app, Swift)

I have an iOS app coded in Swift. I'm displaying a popup on screen using layout constraints.

I was previously using NSLayoutConstraint and centerYAnchor to centre it vertically, but this is no use because the keyboard gets in the way. If I turn off centerYAnchor, it glues itself to the very top of the screen and ends up behind the clock, battery indicator etc.

I'd like to have it just a little bit lower down, but I can't find a way of doing this. I've tried changing view.frame.origin.y but this has no effect - maybe because I'm using NSLayoutConstraint? I can't find a constraint that seems to correspond to x/y coordinates on the screen.

Any help would be most welcome.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source