Last active
March 10, 2021 14:17
-
-
Save HeikkiDev/8674fbc946432a25b5e4e4e02ad71251 to your computer and use it in GitHub Desktop.
Fix blank space on iOS TabbedPage when TabBar is hidden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AdvancedTabbedPageRenderer : TabbedRenderer | |
| { | |
| private Rectangle _initialContainerArea; | |
| public override void ViewDidLayoutSubviews() | |
| { | |
| base.ViewDidLayoutSubviews(); | |
| if (View == null) | |
| { | |
| return; | |
| } | |
| if (!(Element is Page page)) | |
| { | |
| return; | |
| } | |
| _initialContainerArea = page.ContainerArea; | |
| Element.PropertyChanged += OnPropertyChanged; // should be unsubscribed somewhere | |
| if (((AdvancedTabbedPage)Element).IsTabBarVisible == false) | |
| { | |
| // Hide TabBar on page load | |
| TabBar.Hidden = true; | |
| CGRect frame = View.Frame; | |
| page.ContainerArea = new Rectangle(0, 0, frame.Width, frame.Height); | |
| } | |
| } | |
| private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) | |
| { | |
| if (e.PropertyName != AdvancedTabbedPage.IsTabBarVisibleName) | |
| { | |
| return; | |
| } | |
| if (!(Element is Page page)) | |
| { | |
| return; | |
| } | |
| if (((AdvancedTabbedPage)Element).IsTabBarVisible) | |
| { | |
| TabBar.Hidden = false; | |
| page.ContainerArea = _initialContainerArea; | |
| } | |
| else | |
| { | |
| TabBar.Hidden = true; | |
| CGRect frame = View.Frame; | |
| page.ContainerArea = new Rectangle(0, 0, frame.Width, frame.Height); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment