Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2295,10 +2295,34 @@ public override CGRect Frame
value.Width = (value.X - xSpace) + value.Width;
value.X = xSpace;
}

if (_child?.VirtualView is IView view)
{
var margin = view.Margin;

// Apply margins AFTER back button spacing calculations
// Margins push the view inward to keep it within the nav bar bounds
var newWidth = value.Width - (nfloat)(margin.Left + margin.Right);
if (newWidth < 0)
newWidth = 0;

value = new RectangleF(
value.X + (nfloat)margin.Left,
value.Y + (nfloat)margin.Top,
newWidth,
value.Height
);
}
}
;

value.Height = ToolbarHeight;
Copy link
Copy Markdown
Member

@mattleibow mattleibow Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect I think because if you force the height, then if there is a top margin it will be too tall. But maybe this is a feature? I think I would expect that whatever the default is, the margens push it IN or make it smaller.

EDIT

Well, maybe this is all right as margins are more moving the view around. But still, should it be allowed to leave the nav bar?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is complicated because I think Apple doesn’t actually want developers to use the entire height of the navigation bar. That’s why there are those built-in paddings on all sides. Moreover, imo, they changed them in iOS 26. Allowing negative margins is kind of a workaround


// Reduce height by vertical margins so the view stays within the nav bar
if (_child?.VirtualView is IView marginView)
{
var verticalMargin = (nfloat)(marginView.Margin.Top + marginView.Margin.Bottom);
value.Height = (nfloat)Math.Max(0, value.Height - verticalMargin);
}
}

base.Frame = value;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32200.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue32200">
<NavigationPage.TitleView>
<HorizontalStackLayout
BackgroundColor="Blue"
HorizontalOptions="Fill"
VerticalOptions="Fill"
Margin="-20,0,0,0">
<Label Text="1234567890abcdefghij"/>
</HorizontalStackLayout>
</NavigationPage.TitleView>
<Label Text="Hello, Issue 32200"
VerticalOptions="Center"
AutomationId="Label"
HorizontalOptions="Center"/>
</ContentPage>
15 changes: 15 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32200.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 32200, "NavigationPage TitleView iOS 26", PlatformAffected.iOS)]
public class Issue32200NavigationPage : NavigationPage
{
public Issue32200NavigationPage() : base(new Issue32200()) { }
}
public partial class Issue32200 : ContentPage
{
public Issue32200()
{
InitializeComponent();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue32200 : _IssuesUITest
{
public override string Issue => "NavigationPage TitleView iOS 26";
public Issue32200(TestDevice device) : base(device) { }

[Test]
[Category(UITestCategories.Navigation)]
public void NavigationPageTitleViewShouldRespectMargins()
{
App.WaitForElement("Label");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading