- constraints
- An array of UIKit.NSLayoutConstraints to add. The constraints must refer only to the receiving view or its subviews.
The constraints must refer only to the receiving view or its subviews.
In the following example, Visual Format Language specifies that the blueView be horizontally attched to the leading and trailing edge (sides), that the blueView and greenView be vertically attached to the leading and trailing edges (top and bottom) and separated by 30 pixels, and that the greenView be the same width as the blueView and attached to both the leading and trailing edges. The result is shown in the following image.
C# Example
mainView.AddSubview(blueView);
mainView.AddSubview(greenView);
greenView.TranslatesAutoresizingMaskIntoConstraints = false;
blueView.TranslatesAutoresizingMaskIntoConstraints = false;
var viewsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { greenView, blueView}, new NSObject[] { new NSString("green"), new NSString("blue")});
var metrics = new NSDictionary();
mainView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-[blue]-|",0, new NSDictionary(), viewsDictionary));
mainView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-[blue]-(==30)-[green(==blue)]-|",0, new NSDictionary(), viewsDictionary));
mainView.AddConstraints(NSLayoutConstraint.FromVisualFormat("|-[green(==blue)]-|",0, new NSDictionary(), viewsDictionary));
