예제 #1
0
        public static NSLayoutConstraint AlignLeftAnchor(this UIView view, NSLayoutXAxisAnchor anchor, float constant)
        {
            var constraint = view.LeftAnchor.ConstraintEqualTo(anchor, constant);

            constraint.Active = true;
            return(constraint);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
 void AnchorEqual(NSLayoutXAxisAnchor target, NSLayoutXAxisAnchor host, nfloat margin) => target.ConstraintEqualTo(host, margin).Active = true;