public void DidFinishAnimating(UIPageViewController pageViewController, bool finished, UIViewController[] previousViewControllers, bool completed)
        {
            try
            {
                UIViewController v = pageViewController.ViewControllers[0];
                var index          = ViewControllers.IndexOf(v);

                if (index < 0)
                {
                    return;
                }
                SelectedIndex = index;
                PageTabBar.Select(SelectedIndex);

                if (finished && completed)
                {
                    if (Delegate != null)
                    {
                        Delegate.DidTransitionTo(this, v);
                    }
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        internal void HandlePageTabBarButton(UIButton button)
        {
            var index = PageTabBar.Buttons.IndexOf(button);

            if (index < 0 || index == SelectedIndex)
            {
                return;
            }

            var direction = index < SelectedIndex ? UIPageViewControllerNavigationDirection.Reverse : UIPageViewControllerNavigationDirection.Forward;

            IsTabSelectedAnimation = true;
            SelectedIndex          = index;

            PageTabBar.Select(SelectedIndex);

            SetViewControllers(new UIViewController[] { ViewControllers[index] }, direction, true, (finished) =>
            {
                var s = this;
                s.IsTabSelectedAnimation = false;
                if (s.Delegate != null)
                {
                    s.Delegate.DidTransitionTo(s, s.ViewControllers[s.SelectedIndex]);
                }
            });
        }
 private void preparePageTabBar()
 {
     PageTabBar.SetZPosition(1000);
     PageTabBar.SetDividerColor(Color.Grey.Lighten3);
     View.AddSubview(PageTabBar);
     PageTabBar.Select(SelectedIndex);
 }
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();

            var p = PageTabBar.IntrinsicContentSize.Height + PageTabBar.LayoutEdgeInsets().Top + PageTabBar.LayoutEdgeInsets().Bottom;
            var y = View.Height() - p;

            PageTabBar.SetHeight(p);
            PageTabBar.SetWidth(View.Width() + PageTabBar.LayoutEdgeInsets().Left + PageTabBar.LayoutEdgeInsets().Right);

            RootViewController.View.SetHeight(y);

            switch (PageTabBarAlignment)
            {
            case PageTabBarAlignment.Top:
            {
                PageTabBar.SetY(0);
                RootViewController.View.SetY(p);
            }
            break;

            case PageTabBarAlignment.Bottom:
            {
                PageTabBar.SetY(y);
                RootViewController.View.SetY(0);
            }
            break;
            }
        }