Skip to content

Instantly share code, notes, and snippets.

@seansparkman
Last active June 19, 2019 09:09
Show Gist options
  • Save seansparkman/0668871d1dab1c1e7d1fcf3da8cbac33 to your computer and use it in GitHub Desktop.
Save seansparkman/0668871d1dab1c1e7d1fcf3da8cbac33 to your computer and use it in GitHub Desktop.
Fix for Xamarin Forms Shell UseSafeAreaInsets Bug
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
);
}
}
}
}
@mfranc28
Copy link

Great! You save my time....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment