Since the original question is related to Xamarin, I provide a complete C # solution.
First create a height limit for your view and give it an identifier in Xcode Interface Builder:

Then, in the controller, override the ViewDidAppear () method and view using the HidingViewHolder:
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); applePaymentViewHolder = new HidingViewHolder(ApplePaymentFormView, "ApplePaymentFormViewHeightConstraint"); }
It is important to create a HidingViewHolder when the view has been drawn, so it has a real height. To hide or show the view, you can use the appropriate methods:
applePaymentViewHolder.HideView(); applePaymentViewHolder.ShowView();
HidingViewHolder Source:
using System; using System.Linq; using UIKit; /// <summary> /// Helps to hide UIView and remove blank space occupied by invisible view /// </summary> public class HidingViewHolder { private readonly UIView view; private readonly NSLayoutConstraint heightConstraint; private nfloat viewHeight; public HidingViewHolder(UIView view, string heightConstraintId) { this.view = view; this.heightConstraint = view .GetConstraintsAffectingLayout(UILayoutConstraintAxis.Vertical) .SingleOrDefault(x => heightConstraintId == x.GetIdentifier()); this.viewHeight = heightConstraint != null ? heightConstraint.Constant : 0; } public void ShowView() { if (!view.Hidden) { return; } if (heightConstraint != null) { heightConstraint.Active = true; heightConstraint.Constant = viewHeight; } view.Hidden = false; } public void HideView() { if (view.Hidden) { return; } if (heightConstraint != null) { viewHeight = heightConstraint.Constant; heightConstraint.Active = true; heightConstraint.Constant = 0; } view.Hidden = true; } }
source share