I am trying to create a constraint via code:
constraintImageCharacterTop = NSLayoutConstraint (item: image,
attribute: NSLayoutAttribute.Top,
relatedBy: NSLayoutRelation.Equal,
toItem: self.view,
attribute: NSLayoutAttribute.Top,
multiplier: 1,
constant: viewTop)
self.view.addConstraint(constraintImageCharacterTop)
However, I am not sure which is the right NSLayoutAttribute
for this constraint. image
should have a top space to the main Superview self.view
.
This is how I think it works, but I am not sure if I am correct:
Should I use NSLayoutAttribute.Top
or NSLayoutAttribute.TopMargin
for image A?