public static NSLayoutConstraint AlignLeftAnchor(this UIView view, NSLayoutXAxisAnchor anchor, float constant) { var constraint = view.LeftAnchor.ConstraintEqualTo(anchor, constant); constraint.Active = true; return(constraint); }
/// <summary> /// Constraint centreX anchor to an anchor. /// </summary> public static T ConstraintCentreXEqualTo <T>(this T view, NSLayoutXAxisAnchor anchor, nfloat constant = default, LayoutConstraints constraints = default) where T : UIView { var centerXConstraint = view.CenterXAnchor.ConstraintEqualTo(anchor, constant); if (constraints != null) { constraints.CenterX = centerXConstraint; } centerXConstraint.Active = true; return(view); }
/// <summary> /// Constraint trailing anchor to an anchor. /// </summary> public static T ConstraintTrailingEqualTo <T>(this T view, NSLayoutXAxisAnchor anchor, nfloat constant = default, LayoutConstraints constraints = default) where T : UIView { var trailingConstraint = view.TrailingAnchor.ConstraintEqualTo(anchor, -constant); if (constraints != null) { constraints.Trailing = trailingConstraint; } trailingConstraint.Active = true; return(view); }
void AnchorEqual(NSLayoutXAxisAnchor target, NSLayoutXAxisAnchor host, nfloat margin) => target.ConstraintEqualTo(host, margin).Active = true;