NSLayoutConstraint.ActivateConstraints(NSLayoutConstraint[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
啟動所有傳遞的條件約束。
[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);