共用方式為


NSLayoutConstraint.ActivateConstraints(NSLayoutConstraint[]) 方法

定義

啟動所有傳遞的條件約束。

[Foundation.Export("activateConstraints:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 8, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public static void ActivateConstraints (UIKit.NSLayoutConstraint[] constraints);
static member ActivateConstraints : UIKit.NSLayoutConstraint[] -> unit

參數

constraints
NSLayoutConstraint[]

要啟動的條件約束。

屬性

備註

這個方法的效果與將 Active 屬性設定為 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);

適用於