Last active
June 19, 2019 09:09
-
-
Save seansparkman/0668871d1dab1c1e7d1fcf3da8cbac33 to your computer and use it in GitHub Desktop.
Fix for Xamarin Forms Shell UseSafeAreaInsets Bug
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using CommonAlly.iOS.Controls; | |
using Foundation; | |
using UIKit; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Platform.iOS; | |
[assembly: ExportRenderer(typeof(ContentPage), typeof(ContentPageRenderer))] | |
namespace CommonAlly.iOS.Controls | |
{ | |
public class ContentPageRenderer: Xamarin.Forms.Platform.iOS.PageRenderer | |
{ | |
Page Page => Element as Page; | |
public override void ViewDidLayoutSubviews() | |
{ | |
base.ViewDidLayoutSubviews(); | |
UpdateShellInsetPadding(); | |
} | |
public override void ViewSafeAreaInsetsDidChange() | |
{ | |
base.ViewSafeAreaInsetsDidChange(); | |
UpdateShellInsetPadding(); | |
} | |
private void UpdateShellInsetPadding() | |
{ | |
if (Page != null) | |
{ | |
var bottom = 0d; | |
if (Element?.Parent?.Parent is Tab) | |
{ | |
bottom = Page.Padding.Bottom; | |
} | |
Page.Padding = new Thickness( | |
Page.Padding.Left, | |
0, | |
Page.Padding.Right, | |
Page.Padding.Bottom | |
); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! You save my time....