public static NSLayoutConstraint AlignBottomAnchor(this UIView view, NSLayoutYAxisAnchor anchor, float constant) { var constraint = view.BottomAnchor.ConstraintEqualTo(anchor, -constant); constraint.Active = true; return(constraint); }
/// <summary> /// Constraint centreY anchor to an anchor. /// </summary> public static T ConstraintCentreYEqualTo <T>(this T view, NSLayoutYAxisAnchor anchor, nfloat constant = default, LayoutConstraints constraints = default) where T : UIView { var centerYConstraint = view.CenterYAnchor.ConstraintEqualTo(anchor, constant); if (constraints != null) { constraints.CenterY = centerYConstraint; } centerYConstraint.Active = true; return(view); }
/// <summary> /// Constraint bottom anchor to an anchor. /// </summary> public static T ConstraintBottomEqualTo <T>(this T view, NSLayoutYAxisAnchor anchor, nfloat constant = default, LayoutConstraints constraints = default) where T : UIView { var bottomConstraint = view.BottomAnchor.ConstraintEqualTo(anchor, -constant); if (constraints != null) { constraints.Bottom = bottomConstraint; } bottomConstraint.Active = true; return(view); }
/// <summary> /// Constraint top anchor to an anchor. /// </summary> public static T ConstraintTopEqualTo <T>(this T view, NSLayoutYAxisAnchor anchor, nfloat constant = default, LayoutConstraints constraints = default) where T : UIView { var topConstraint = view.TopAnchor.ConstraintEqualTo(anchor, constant); if (constraints != null) { constraints.Top = topConstraint; } topConstraint.Active = true; return(view); }
void AnchorEqual(NSLayoutYAxisAnchor target, NSLayoutYAxisAnchor host, nfloat margin) => target.ConstraintEqualTo(host, margin).Active = true;