NSLayoutConstraint Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A relationship between two layout attributes used in a constraint-based layout.
[Foundation.Register("NSLayoutConstraint", true)]
public class NSLayoutConstraint : Foundation.NSObject
[<Foundation.Register("NSLayoutConstraint", true)>]
type NSLayoutConstraint = class
inherit NSObject
- Inheritance
- Attributes
Remarks
An NSLayoutConstraint specifies the relationship between two layout attributes (FirstAttribute and SecondAttribute, both of which are of type NSLayoutAttribute) in a constraint-based layout.
The relationship consists of:
- A NSLayoutRelation (e.g., GreaterThanOrEqual):
- A floating point Multiplier:
- A single-precision floating point Constant:
- A floating point Priority. Constraints with higher priorities are satisfied before constraints with lower priorities.:
The constraint engine will set the value of the FirstAttribute such that it satisfies the constraint FirstAttribute <Relation> <Constant> + <Multiplier> * <SecondAttribute>. For instance, in the following code from the "Media Notes" sample, tconstraint2 is a constraint that specifies that the top of the toolbar is going to be equal to the top of the View plus the value of the toolbarVerticalOffset, while tconstraint1 specifies that the width of the toolbar will be equal to the width of the View. Both of these constraints have a Priority of 1.0.
var tconstraint2 = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Top, NSLayoutRelation.Equal,
View, NSLayoutAttribute.Top, 1.0f, toolbarVerticalOffset);
toolbarTopConstraint = tconstraint2;
var tconstraint1 = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Width, NSLayoutRelation.Equal,
View, NSLayoutAttribute.Width, 1.0f, 0.0f);
Constructors
| Name | Description |
|---|---|
| NSLayoutConstraint() |
Creates a new NSLayoutConstraint with default values. |
| NSLayoutConstraint(NativeHandle) |
A constructor used when creating managed representations of unmanaged objects. Called by the runtime. |
| NSLayoutConstraint(NSObjectFlag) |
Constructor to call on derived classes to skip initialization and merely allocate the object. |
Properties
| Name | Description |
|---|---|
| AccessibilityAttributedUserInputLabels | (Inherited from NSObject) |
| AccessibilityRespondsToUserInteraction | (Inherited from NSObject) |
| AccessibilityTextualContext | (Inherited from NSObject) |
| AccessibilityUserInputLabels | (Inherited from NSObject) |
| Active |
Controls whether the constraint is active. Active constraints are used as part of the auto-layout process, those that are not are ignored. |
| Class | (Inherited from NSObject) |
| ClassHandle |
The Objective-C class handle for this class. |
| Constant |
Indicates the constant float applied to the constraint. |
| DebugDescription | (Inherited from NSObject) |
| Description | (Inherited from NSObject) |
| FirstAttribute |
The attribute of the first item participating in the constraint. |
| FirstItem |
The first item participating in the constraint. |
| Handle |
Handle (pointer) to the unmanaged object representation. (Inherited from NSObject) |
| Identifier | |
| IsDirectBinding | (Inherited from NSObject) |
| IsProxy | (Inherited from NSObject) |
| Multiplier |
Applied to the second attribute participating in the constraint. |
| Priority |
The priority of the constraint. Must be in range [0, UILayoutPriority.Required]. |
| Relation |
The NSRelation that holds between the two items in the constraint. |
| RetainCount | (Inherited from NSObject) |
| SecondAttribute |
The attribute of the second item participating in the constraint. |
| SecondItem |
The second item participating in the constraint. |
| Self | (Inherited from NSObject) |
| ShouldBeArchived |
Whether the constraint should be archived by its owning UIView. |
| Superclass | (Inherited from NSObject) |
| SuperHandle |
Handle used to represent the methods in the base class for this NSObject. (Inherited from NSObject) |
| Zone | (Inherited from NSObject) |