private void SetUpChildViewController() { ChildViewController.WillMoveToParentViewController(this); AddChildViewController(ChildViewController); ContainerView.TranslatesAutoresizingMaskIntoConstraints = false; ChildViewController.View.TranslatesAutoresizingMaskIntoConstraints = false; ContainerView.AddSubview(ChildViewController.View); var bottomInset = this.AdditionalSafeAreaInsets.Bottom; ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ChildViewController.View, NSLayoutAttribute.Top, 1, 0)); ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ChildViewController.View, NSLayoutAttribute.Bottom, 1, bottomInset)); ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ChildViewController.View, NSLayoutAttribute.Leading, 1, 0)); ContainerView.AddConstraint(NSLayoutConstraint.Create(ContainerView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ChildViewController.View, NSLayoutAttribute.Trailing, 1, 0)); if (RoundTopCorner) { ChildViewController.View.Layer.MaskedCorners = CoreAnimation.CACornerMask.MaxXMinYCorner | CoreAnimation.CACornerMask.MinXMinYCorner; ChildViewController.View.Layer.CornerRadius = 10; ChildViewController.View.Layer.MasksToBounds = true; } ChildViewController.DidMoveToParentViewController(this); }
/// <summary> /// Shows the tab with the specified tag. /// </summary> /// <param name="tag">The tag assigned to the tab to show.</param> protected void ShowTab(nint tag) { if (tag != this.currentItemTag) { ChildViewController childController = this.LoadChildViewController(tag); if (this.currentChildController != null) { this.currentChildController.ViewWillDisappear(false); this.currentChildController.View.RemoveFromSuperview(); this.currentChildController.RemoveFromParentViewController(); } this.AddChildViewController(childController.Instance); childController.Instance.DidMoveToParentViewController(this); childController.Instance.ViewWillAppear(false); this.InsertAndLayoutTabView(childController.Instance); if (this.UseChildNavigationItem) { childController.InitializeNavigationBar(); this.SetNavigationItemFromChild(childController.Instance); } if (this.currentChildController != null) { this.currentChildController.ViewDidDisappear(false); } childController.Instance.ViewDidAppear(false); this.currentChildController = childController.Instance; this.currentItemTag = tag; } }