diff --git a/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs index 01b24e9694d0..b209b3dc9db7 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs @@ -1946,31 +1946,20 @@ public Container(View view, UINavigationBar bar) : base(bar.Bounds) ClipsToBounds = true; } - UIEdgeInsets CalculateUIEdgeInsets() + public override UIEdgeInsets AlignmentRectInsets { - var type = UIBarButtonSystemItem.FixedSpace; - var spacer = new UIBarButtonItem(type, (_, _) => { }); - spacer.Width = SystemMargin + (OperatingSystem.IsIOSVersionAtLeast(11) ? 8 : -16); - - nfloat screenWidth = UIScreen.MainScreen.Bounds.Size.Width; - - if (!OperatingSystem.IsIOSVersionAtLeast(11) && screenWidth < 375) - { - // 3.5 and 4 inch - spacer.Width += 8; - } - else if (screenWidth >= 414) + get { - // 5.5 inch - spacer.Width -= 4; + if (_child?.VirtualView is IView view) + { + var margin = view.Margin; + return new UIEdgeInsets(-(nfloat)margin.Top, -(nfloat)margin.Left, -(nfloat)margin.Bottom, -(nfloat)margin.Right); + } + else + { + return base.AlignmentRectInsets; + } } - - return new UIEdgeInsets(0, spacer.Width, 0, spacer.Width); - } - - public override UIEdgeInsets AlignmentRectInsets - { - get => CalculateUIEdgeInsets(); } void OnTitleViewParentSet(object sender, EventArgs e) diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png index d865bf49c869..3c3b26edfb50 100644 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png index f1adf99ddb55..6376a9b52a46 100644 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TitleIcon_And_TitleView_Persist_On_Push_Then_Clear.png differ