Custom TabbedRenderer - Tabbar on the top on iOS












0















I am doing a CustomTabbedRenderer to set the tabbar at the top of the page on iOS.
These TopTabbedBar is nested as a tab of a root tabbedpage.



I first get what I want (see the image):
right layout
But when I select another tab, the Page.ContainerArea is resized (see the image) , and the coontrol is behind the tabbar.
bad layout



public class TabbedPageCustomRenderer : TabbedRenderer
{
bool _loaded;
Size _queuedSize;



Page Page => Element as Page;


public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();

if (Element == null)
return;

if (!Element.Bounds.IsEmpty)
{
// I add "(loat)10" to shift the View.Frame under the statusbar

View.Frame = new System.Drawing.RectangleF((float)Element.X, (float)10, (float)Element.Width, (float)(Element.Height-10));
}

var tabBarFrame = TabBar.Frame;

var frame = ParentViewController != null ? ParentViewController.View.Frame : View.Frame;
var height = frame.Height - tabBarFrame.Height;

// I add "tabBarFrame.Height" to shift the "Page.ContainerArea" under the Tabbar
Page.ContainerArea = new Rectangle(0, tabBarFrame.Height, frame.Width, height);


if (!_queuedSize.IsZero)
{
Element.Layout(new Rectangle(Element.X, Element.Y, _queuedSize.Width, _queuedSize.Height));
_queuedSize = Size.Zero;
}

_loaded = true;
}

public override void ViewWillLayoutSubviews()
{
base.ViewWillLayoutSubviews();
this.TabBar.InvalidateIntrinsicContentSize();


nfloat tabSize = 44.0f;

UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation;

if (UIInterfaceOrientation.LandscapeLeft == orientation || UIInterfaceOrientation.LandscapeRight == orientation)
{
tabSize = 32.0f;
}

var tabFrame = this.TabBar.Frame;
tabFrame.Height = tabSize;
tabFrame.Y = View.Frame.Y;
this.TabBar.Frame = tabFrame;

//this.TabBar.TopAnchor = false;
this.TabBar.Translucent = false;
this.TabBar.Translucent = true;
}
}


I find out when tapping on a new tab, that the "SafeAreaInsets" is been reset. May be it is the problem.



Can you help me, please.










share|improve this question



























    0















    I am doing a CustomTabbedRenderer to set the tabbar at the top of the page on iOS.
    These TopTabbedBar is nested as a tab of a root tabbedpage.



    I first get what I want (see the image):
    right layout
    But when I select another tab, the Page.ContainerArea is resized (see the image) , and the coontrol is behind the tabbar.
    bad layout



    public class TabbedPageCustomRenderer : TabbedRenderer
    {
    bool _loaded;
    Size _queuedSize;



    Page Page => Element as Page;


    public override void ViewDidLayoutSubviews()
    {
    base.ViewDidLayoutSubviews();

    if (Element == null)
    return;

    if (!Element.Bounds.IsEmpty)
    {
    // I add "(loat)10" to shift the View.Frame under the statusbar

    View.Frame = new System.Drawing.RectangleF((float)Element.X, (float)10, (float)Element.Width, (float)(Element.Height-10));
    }

    var tabBarFrame = TabBar.Frame;

    var frame = ParentViewController != null ? ParentViewController.View.Frame : View.Frame;
    var height = frame.Height - tabBarFrame.Height;

    // I add "tabBarFrame.Height" to shift the "Page.ContainerArea" under the Tabbar
    Page.ContainerArea = new Rectangle(0, tabBarFrame.Height, frame.Width, height);


    if (!_queuedSize.IsZero)
    {
    Element.Layout(new Rectangle(Element.X, Element.Y, _queuedSize.Width, _queuedSize.Height));
    _queuedSize = Size.Zero;
    }

    _loaded = true;
    }

    public override void ViewWillLayoutSubviews()
    {
    base.ViewWillLayoutSubviews();
    this.TabBar.InvalidateIntrinsicContentSize();


    nfloat tabSize = 44.0f;

    UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation;

    if (UIInterfaceOrientation.LandscapeLeft == orientation || UIInterfaceOrientation.LandscapeRight == orientation)
    {
    tabSize = 32.0f;
    }

    var tabFrame = this.TabBar.Frame;
    tabFrame.Height = tabSize;
    tabFrame.Y = View.Frame.Y;
    this.TabBar.Frame = tabFrame;

    //this.TabBar.TopAnchor = false;
    this.TabBar.Translucent = false;
    this.TabBar.Translucent = true;
    }
    }


    I find out when tapping on a new tab, that the "SafeAreaInsets" is been reset. May be it is the problem.



    Can you help me, please.










    share|improve this question

























      0












      0








      0








      I am doing a CustomTabbedRenderer to set the tabbar at the top of the page on iOS.
      These TopTabbedBar is nested as a tab of a root tabbedpage.



      I first get what I want (see the image):
      right layout
      But when I select another tab, the Page.ContainerArea is resized (see the image) , and the coontrol is behind the tabbar.
      bad layout



      public class TabbedPageCustomRenderer : TabbedRenderer
      {
      bool _loaded;
      Size _queuedSize;



      Page Page => Element as Page;


      public override void ViewDidLayoutSubviews()
      {
      base.ViewDidLayoutSubviews();

      if (Element == null)
      return;

      if (!Element.Bounds.IsEmpty)
      {
      // I add "(loat)10" to shift the View.Frame under the statusbar

      View.Frame = new System.Drawing.RectangleF((float)Element.X, (float)10, (float)Element.Width, (float)(Element.Height-10));
      }

      var tabBarFrame = TabBar.Frame;

      var frame = ParentViewController != null ? ParentViewController.View.Frame : View.Frame;
      var height = frame.Height - tabBarFrame.Height;

      // I add "tabBarFrame.Height" to shift the "Page.ContainerArea" under the Tabbar
      Page.ContainerArea = new Rectangle(0, tabBarFrame.Height, frame.Width, height);


      if (!_queuedSize.IsZero)
      {
      Element.Layout(new Rectangle(Element.X, Element.Y, _queuedSize.Width, _queuedSize.Height));
      _queuedSize = Size.Zero;
      }

      _loaded = true;
      }

      public override void ViewWillLayoutSubviews()
      {
      base.ViewWillLayoutSubviews();
      this.TabBar.InvalidateIntrinsicContentSize();


      nfloat tabSize = 44.0f;

      UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation;

      if (UIInterfaceOrientation.LandscapeLeft == orientation || UIInterfaceOrientation.LandscapeRight == orientation)
      {
      tabSize = 32.0f;
      }

      var tabFrame = this.TabBar.Frame;
      tabFrame.Height = tabSize;
      tabFrame.Y = View.Frame.Y;
      this.TabBar.Frame = tabFrame;

      //this.TabBar.TopAnchor = false;
      this.TabBar.Translucent = false;
      this.TabBar.Translucent = true;
      }
      }


      I find out when tapping on a new tab, that the "SafeAreaInsets" is been reset. May be it is the problem.



      Can you help me, please.










      share|improve this question














      I am doing a CustomTabbedRenderer to set the tabbar at the top of the page on iOS.
      These TopTabbedBar is nested as a tab of a root tabbedpage.



      I first get what I want (see the image):
      right layout
      But when I select another tab, the Page.ContainerArea is resized (see the image) , and the coontrol is behind the tabbar.
      bad layout



      public class TabbedPageCustomRenderer : TabbedRenderer
      {
      bool _loaded;
      Size _queuedSize;



      Page Page => Element as Page;


      public override void ViewDidLayoutSubviews()
      {
      base.ViewDidLayoutSubviews();

      if (Element == null)
      return;

      if (!Element.Bounds.IsEmpty)
      {
      // I add "(loat)10" to shift the View.Frame under the statusbar

      View.Frame = new System.Drawing.RectangleF((float)Element.X, (float)10, (float)Element.Width, (float)(Element.Height-10));
      }

      var tabBarFrame = TabBar.Frame;

      var frame = ParentViewController != null ? ParentViewController.View.Frame : View.Frame;
      var height = frame.Height - tabBarFrame.Height;

      // I add "tabBarFrame.Height" to shift the "Page.ContainerArea" under the Tabbar
      Page.ContainerArea = new Rectangle(0, tabBarFrame.Height, frame.Width, height);


      if (!_queuedSize.IsZero)
      {
      Element.Layout(new Rectangle(Element.X, Element.Y, _queuedSize.Width, _queuedSize.Height));
      _queuedSize = Size.Zero;
      }

      _loaded = true;
      }

      public override void ViewWillLayoutSubviews()
      {
      base.ViewWillLayoutSubviews();
      this.TabBar.InvalidateIntrinsicContentSize();


      nfloat tabSize = 44.0f;

      UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation;

      if (UIInterfaceOrientation.LandscapeLeft == orientation || UIInterfaceOrientation.LandscapeRight == orientation)
      {
      tabSize = 32.0f;
      }

      var tabFrame = this.TabBar.Frame;
      tabFrame.Height = tabSize;
      tabFrame.Y = View.Frame.Y;
      this.TabBar.Frame = tabFrame;

      //this.TabBar.TopAnchor = false;
      this.TabBar.Translucent = false;
      this.TabBar.Translucent = true;
      }
      }


      I find out when tapping on a new tab, that the "SafeAreaInsets" is been reset. May be it is the problem.



      Can you help me, please.







      xamarin.forms xamarin.ios tabbar tabbedpage






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 18:46









      JeffJeff

      114




      114
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326055%2fcustom-tabbedrenderer-tabbar-on-the-top-on-ios%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326055%2fcustom-tabbedrenderer-tabbar-on-the-top-on-ios%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Lugert, Oklahoma