This is the code I'm trying out:
@IBOutlet weak var btnInfo: UIButton!
override func viewWillAppear(_ animated: Bool) {
self.view.addConstraint(NSLayoutConstraint(item: self.view,
attribute: .topMargin,
relatedBy: .equal,
toItem: btnInfo,
attribute: .notAnAttribute,
multiplier: 1,
constant: 20))
self.view.addConstraint(NSLayoutConstraint(item: self.view,
attribute: .rightMargin,
relatedBy: .equal,
toItem: btnInfo,
attribute: .notAnAttribute,
multiplier: 1,
constant: 30))
}
Trying to add .topMargin
and .rightMargin
constraints to get the btnInfo
to appear 30 points from top and 30 from right margin. Please help.