Share via


NSLayoutConstraint.ActivateConstraints(NSLayoutConstraint[]) Method

Definition

Activates all of the constraints passed.

[Foundation.Export("activateConstraints:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public static void ActivateConstraints(AppKit.NSLayoutConstraint[] constraints);
[<Foundation.Export("activateConstraints:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
static member ActivateConstraints : AppKit.NSLayoutConstraint[] -> unit

Parameters

constraints
NSLayoutConstraint[]

Constraints to activate.

Attributes

Remarks

This method has the same effect as setting the Active property to true.

var blueView = new ContentView(UIColor.Blue);
view.AddSubview(blueView);

blueView.TranslatesAutoresizingMaskIntoConstraints = false;
var blueConstraints = new []
{ 
blueView.LeadingAnchor.ConstraintEqualTo(greenView.LeadingAnchor),
blueView.TrailingAnchor.ConstraintEqualTo(greenView.TrailingAnchor),
blueView.TopAnchor.ConstraintEqualTo(greenView.BottomAnchor, 10.0f),
blueView.HeightAnchor.ConstraintEqualTo(greenView.HeightAnchor),
blueView.WidthAnchor.ConstraintEqualTo(greenView.WidthAnchor)
};

NSLayoutConstraint.ActivateConstraints(blueConstraints);

Applies to