Let suppose your UIImageView
is added in the top as you put in your image above, then you can add constraints programmatically like in the following way:
override func viewDidLoad() {
super.viewDidLoad()
// assuming here you have added the self.imageView to the main view and it was declared before.
self.imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
// create the constraints with the constant value you want.
var verticalSpace = NSLayoutConstraint(item: self.imageView, attribute: .Bottom, relatedBy: .Equal, toItem: self.button, attribute: .Bottom, multiplier: 1, constant: 50)
// activate the constraints
NSLayoutConstraint.activateConstraints([verticalSpace])
}
In the above code I only put the vertical space constraints, you need to set the necessary constraints to avoid warnings about it.
There are several ways of adding constraint programmatically you can read more in this very nice answer SWIFT | Adding constraints programmatically.
I hope this help you.