Example #1
0
        /// <summary>
        /// Centers the view both vertically and horizontally to the center of another view.
        /// </summary>
        /// <param name="view">A view to center.</param>
        /// <param name="secondView">The second view to center to.</param>
        /// <returns>The NSLayoutConstraints for the anchor.</returns>
        public static NSLayoutConstraint[] AnchorCenter(this UIView view, UIView secondView)
        {
            NSLayoutConstraint[] constraints = new NSLayoutConstraint[2];

            constraints[0] = view.AnchorCenterX(secondView);
            constraints[1] = view.AnchorCenterY(secondView);

            return(constraints);
        }
Example #2
0
 /// <summary>
 /// Centers the view vertically to the parent.
 /// </summary>
 /// <param name="view">A view to center.</param>
 /// <param name="constant">An optional offset value when centering.</param>
 /// <returns>The NSLayoutConstraint for the anchor.</returns>
 public static NSLayoutConstraint AnchorCenterY(this UIView view, float constant = 0)
 {
     UIViewExtensions.EnsureHasParent(view);
     return(view.AnchorCenterY(view.Superview, constant));
 }