diff --git a/docs/api/UIKit/NSLayoutConstraint.xml b/docs/api/UIKit/NSLayoutConstraint.xml
index 23cd25c31edf..ad03150f3679 100644
--- a/docs/api/UIKit/NSLayoutConstraint.xml
+++ b/docs/api/UIKit/NSLayoutConstraint.xml
@@ -31,25 +31,6 @@ var tconstraint1 = NSLayoutConstraint.Create (toolbar, NSLayoutAttribute.Width,
Apple documentation for NSLayoutConstraint
-
- Visual format to use to create the constraints.
- options.
-
- Pairs of names and values. The names should be strings (or NSStrings) and the values should be either UIViews, numbers (any C# number or NSNumber) or instances that are suitable to be passed to the underlying engine.
-
-
- This binds the provided name with the view or binds the name with the number as a metric.
-
- Factory method for creating a constraint using Visual Format Language.
- An array of layout constraints that are suitable to be added to a using method.
-
-
-
-
-
-
Constraints to activate.
Activates all of the constraints passed.
@@ -93,32 +74,6 @@ NSLayoutConstraint.ActivateConstraints(blueConstraints);
It is easier to use the overload as it combines support for both metrics and views in a single call.
-
- First view in the constraint.
- Attribute for the first view.
- Relationships between the and the .
-
- Second view in the constraint.
- This parameter can be .
- This parameter can be .
-
- Attribute for the second view.
- Multiplier applied to the second attribute.
- Constants to add.
- Factory method for creating a constraint.
-
- New constraint with the specified parameters.
-
-
-
-
- Creates a constraint relationship between the and the that satisfies the following linear equation:
-
-
-
- = x +
-
-
First view in the constraint.
Attribute for the first view.
diff --git a/src/Foundation/NSLayoutConstraint.cs b/src/Foundation/NSLayoutConstraint.cs
index 0361bd73c801..fac7a430c1aa 100644
--- a/src/Foundation/NSLayoutConstraint.cs
+++ b/src/Foundation/NSLayoutConstraint.cs
@@ -1,10 +1,10 @@
//
-// Helper functions to make FromVisualLayout more palattable
+// Helper functions to make FromVisualFormat more palatable
//
// Author:
// Miguel de Icaza
//
-// Copyright 2014 Xamarin INc
+// Copyright 2014 Xamarin Inc
//
#if MONOMAC
@@ -13,8 +13,7 @@
using View = UIKit.UIView;
#endif
-// Disable until we get around to enable + fix any issues.
-#nullable disable
+#nullable enable
#if MONOMAC
namespace AppKit
@@ -23,7 +22,7 @@ namespace UIKit
#endif
{
public partial class NSLayoutConstraint {
- static NSNumber AsNumber (object o)
+ static NSNumber? AsNumber (object o)
{
if (o is NSNumber) return (NSNumber) o;
if (o is double) return new NSNumber ((double) o);
@@ -42,10 +41,26 @@ static NSNumber AsNumber (object o)
return null;
}
- ///
+ /// Factory method for creating a constraint using Visual Format Language.
+ /// Visual format to use to create the constraints.
+ /// Options for the format.
+ ///
+ /// Pairs of names and values. The names should be strings (or ) and the values should be either s, numbers (any C# number or ) or instances that are suitable to be passed to the underlying engine.
+ /// This binds the provided name with the view or binds the name with the number as a metric.
+ ///
+ /// An array of layout constraints that are suitable to be added to a using the method.
+ ///
+ ///
+ ///
+ ///
+ ///
static public NSLayoutConstraint [] FromVisualFormat (string format, NSLayoutFormatOptions formatOptions, params object [] viewsAndMetrics)
{
- NSMutableDictionary views = null, metrics = null;
+ ArgumentNullException.ThrowIfNull (format);
+ ArgumentNullException.ThrowIfNull (viewsAndMetrics);
+ NSMutableDictionary? views = null, metrics = null;
var count = viewsAndMetrics.Length;
if (count != 0) {
if ((count % 2) != 0)
@@ -102,60 +117,60 @@ static public NSLayoutConstraint [] FromVisualFormat (string format, NSLayoutFor
return FromVisualFormat (format, formatOptions, metrics, views);
}
- /// To be added.
- /// To be added.
- /// To be added.
- /// To be added.
- /// To be added.
- /// Static factory method for creating a constraint.
- /// To be added.
- /// To be added.
+ /// Factory method for creating a constraint.
+ /// The view or object in the constraint.
+ /// The attribute for the view.
+ /// The relationship in the constraint.
+ /// The multiplier applied to the attribute.
+ /// The constant value in the constraint.
+ /// A new constraint with the specified parameters.
+ /// Creates a constraint for a single view with a specified attribute, relation, multiplier, and constant value.
public static NSLayoutConstraint Create (NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation, nfloat multiplier, nfloat constant)
{
return NSLayoutConstraint.Create (view1, attribute1, relation, null, NSLayoutAttribute.NoAttribute, multiplier, constant);
}
- /// To be added.
- /// To be added.
- /// To be added.
- /// Static factory method to create a constraint based on a , an , and an .
- /// To be added.
- /// To be added.
+ /// Factory method to create a constraint based on a , an , and an .
+ /// The view or object in the constraint.
+ /// The attribute for the view.
+ /// The relationship in the constraint.
+ /// A new constraint with the specified parameters and default multiplier (1.0) and constant (0.0).
+ /// Creates a constraint for a single view with default multiplier and constant values.
public static NSLayoutConstraint Create (NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation)
{
return NSLayoutConstraint.Create (view1, attribute1, relation, null, NSLayoutAttribute.NoAttribute, 1.0f, 0f);
}
- // This solves the duplicate selector export problem while not breaking the API.
- ///
+ /// Factory method for creating a constraint.
+ /// First view in the constraint.
+ /// Attribute for the first view.
+ /// Relationship between the and the .
+ /// Second view in the constraint. This parameter can be .
+ /// Attribute for the second view.
+ /// Multiplier applied to the second attribute.
+ /// Constant to add.
+ /// A new constraint with the specified parameters.
+ /// Creates a constraint relationship between the and the that satisfies the following linear equation: = x + .
public static NSLayoutConstraint Create (NSObject view1, NSLayoutAttribute attribute1, NSLayoutRelation relation,
- NSObject view2, NSLayoutAttribute attribute2, nfloat multiplier, nfloat constant)
+ NSObject? view2, NSLayoutAttribute attribute2, nfloat multiplier, nfloat constant)
{
return Create ((INativeObject) view1, attribute1, relation, view2, attribute2, multiplier, constant);
}
- /// To be added.
- /// For an anchor-based constraint, returns the first anchor, properly downcast to AnchorType.
- /// To be added.
- /// To be added.
- [SupportedOSPlatform ("ios")]
- [SupportedOSPlatform ("maccatalyst")]
- [SupportedOSPlatform ("tvos")]
- [SupportedOSPlatform ("macos")]
- public NSLayoutAnchor FirstAnchor () where AnchorType : NSObject
+ /// For an anchor-based constraint, returns the first anchor, properly downcast to .
+ /// The type of anchor to return.
+ /// The first anchor of the constraint, cast to the specified anchor type.
+ /// This method is useful for retrieving the first anchor when working with anchor-based constraints.
+ public NSLayoutAnchor? FirstAnchor () where AnchorType : NSObject
{
return Runtime.GetNSObject> (_FirstAnchor ());
}
- /// To be added.
- /// For an anchor-based constraint, returns the second anchor, properly downcast to AnchorType.
- /// To be added.
- /// To be added.
- [SupportedOSPlatform ("ios")]
- [SupportedOSPlatform ("maccatalyst")]
- [SupportedOSPlatform ("tvos")]
- [SupportedOSPlatform ("macos")]
- public NSLayoutAnchor SecondAnchor () where AnchorType : NSObject
+ /// For an anchor-based constraint, returns the second anchor, properly downcast to .
+ /// The type of anchor to return.
+ /// The second anchor of the constraint, cast to the specified anchor type.
+ /// This method is useful for retrieving the second anchor when working with anchor-based constraints.
+ public NSLayoutAnchor? SecondAnchor () where AnchorType : NSObject
{
return Runtime.GetNSObject> (_SecondAnchor ());
}