Skip to content

Fix iOS 26 TitleView covering content in Shell and NavigationPage#32341

Merged
PureWeen merged 12 commits intomainfrom
copilot/fix-covering-titleview-issue
Nov 21, 2025
Merged

Fix iOS 26 TitleView covering content in Shell and NavigationPage#32341
PureWeen merged 12 commits intomainfrom
copilot/fix-covering-titleview-issue

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description

Fixes custom TitleView covering page content on iOS 26 by switching from Auto Layout constraints to autoresizing masks. On iOS 26+, the navigation bar layout behavior changed, causing TitleView containers using constraints to expand beyond the navigation bar bounds and cover the underlying content, making it uninteractable.

Root Cause

iOS 26 changed how navigation bar title views are laid out. When using Auto Layout constraints (the approach for iOS 11-25), the TitleView container expands beyond the navigation bar bounds and covers the shell/page content below.

Solution

For iOS 26+ and MacCatalyst 26+:

  • Switch from Auto Layout constraints to autoresizing masks
  • Explicitly set container frame to match navigation bar dimensions
  • Use actual navigation bar height instead of hardcoded 44pt
  • Proper fallback handling when navigation bar frame unavailable

Changes Made

Shell TitleViewContainer (ShellPageRendererTracker.cs)

  • Added CreateTitleViewContainer helper method for centralized container creation
  • Added constructor overload accepting navigation bar frame for iOS 26+
  • Implemented iOS 26+ version detection with autoresizing mask configuration
  • Added comprehensive XML documentation

NavigationPage Container (NavigationRenderer.cs)

  • Added CreateTitleViewContainer helper method matching Shell implementation
  • Added constructor overload with navigation bar frame parameter
  • Refactored initialization using InitializeContainer method
  • Updated ToolbarHeight property to use actual nav bar height (eliminates hardcoded 44pt)
  • iOS 26+ handling for both TitleView layout and height calculation

Technical Details

iOS Version Handling

  • iOS 11-25: Uses Auto Layout constraints (existing behavior)
  • iOS 26+: Uses autoresizing masks with explicit frame sizing
  • Pre-iOS 11: Uses autoresizing masks (existing behavior)

Frame Management

  • Frame origin explicitly set to (0, 0) - positioning handled by navigation bar
  • Frame dimensions match navigation bar width and height
  • Fallback to standard constructor if navigation bar frame unavailable

Issues Fixed

Fixes #32287
Fixes #32777

Related Issues

Similar iOS version-specific TitleView fixes: #31831, #31701, #20959 (iOS 16), #12834

Original prompt

This section details on the original issue you should resolve

<issue_title>Using custom TitleView in AppShell causes shell content to be covered in iOS 26</issue_title>
<issue_description>When using a custom view for the Shell's TitleView on iOS 26, the title view ends up covering the content Shell is currently displaying. See the below screenshot.

Image

When in this state, the content cannot be interacted with.

This is using the base MAUI template with a slight modification to add a custom TItleView. Here's the AppShell.xaml.

<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="TitleViewIssue.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:TitleViewIssue"
    Title="TitleViewIssue">
    
    <Shell.TitleView>
<!-- 
        This label covers the entire app and isn't contained in the title view itself.
        A workaround is to either set VerticalOptions="Center" or to give it an explicit
        HeightRequest, but neither are necessary pre-iOS 26.
-->
        <Label Text="I'm a custom title"
               FontSize="20"
               HorizontalTextAlignment="Center"
               VerticalTextAlignment="Center"/>
    </Shell.TitleView>

    <ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />

</Shell>

This same code doesn't have this issue when built with an older MAUI iOS workload targeting iOS 18.5.

A workaround I've found is to manually specify VerticalOptions="Center" or to set HeightRequest on the view inside <Shell.TitleView>.

Attached is a sample project that reproduces the issue.

TitleViewIssue.zip</issue_description>

<agent_instructions>Use the custom agent in https://github.com/dotnet/maui/blob/pr-reviewer/.github/agents/pr-reviewer.md that is on the "pr-reviewer" branch to review this pull request #32337 for issue #32287.

So take the PR that was created and use the custom agent at https://github.com/dotnet/maui/blob/pr-reviewer/.github/agents/pr-reviewer.md to review and add to that PR.

Don't assume that the PR is correct, it's ok to challenge the fix and see if you can come up with a better fix.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix issue with custom TitleView covering shell content in iOS 26 Review of PR #32337: Shell TitleView iOS 26 layout fix needs refinement Nov 2, 2025
Copilot AI requested a review from PureWeen November 2, 2025 22:32
@PureWeen
Copy link
Member

PureWeen commented Nov 2, 2025

@copilot Implement my own fix based on my review insights and write a PR description for that new implementation

Copy link
Contributor Author

Copilot AI commented Nov 2, 2025

@copilot Implement my own fix based on my review insights and write a PR description for that new implementation

Implemented an improved fix based on the review insights in commit 66e1443.

Key improvements over PR #32337:

  1. Eliminated silent failure: Added CreateTitleViewContainer helper method with explicit fallback when navigation bar frame is unavailable
  2. Fixed frame positioning: Set origin to (0,0) instead of preserving potentially uninitialized X/Y coordinates
  3. Reduced code duplication: Single method handles iOS version detection and container creation
  4. Enhanced documentation: Added comprehensive XML docs explaining the iOS 26 workaround

The solution maintains the core approach (autoresizing masks for iOS 26+) but addresses the robustness and maintainability concerns identified in the review.

Copilot AI changed the title Review of PR #32337: Shell TitleView iOS 26 layout fix needs refinement Fix Shell TitleView covering content on iOS 26 Nov 2, 2025
@kubaflo
Copy link
Contributor

kubaflo commented Nov 2, 2025

@copilot Currently, this change only affects the Shell navigation bar’s TitleView. However, in .NET MAUI developers can also define a TitleView for a standard NavigationPage, like this:

<NavigationPage.TitleView>
    <Label Text="I'm a custom title"
           FontSize="20"
           BackgroundColor="Green"
           HorizontalTextAlignment="Center"
           VerticalTextAlignment="Center" />
</NavigationPage.TitleView>

I recommend applying a similar fix to this implementation as well.
At the moment, the navigation bar height for iOS 26+ is hardcoded to 44, which is both incorrect (since iOS 26+ uses a taller navigation bar) and unreliable.

1 similar comment
@PureWeen
Copy link
Member

PureWeen commented Nov 2, 2025

@copilot Currently, this change only affects the Shell navigation bar’s TitleView. However, in .NET MAUI developers can also define a TitleView for a standard NavigationPage, like this:

<NavigationPage.TitleView>
    <Label Text="I'm a custom title"
           FontSize="20"
           BackgroundColor="Green"
           HorizontalTextAlignment="Center"
           VerticalTextAlignment="Center" />
</NavigationPage.TitleView>

I recommend applying a similar fix to this implementation as well.
At the moment, the navigation bar height for iOS 26+ is hardcoded to 44, which is both incorrect (since iOS 26+ uses a taller navigation bar) and unreliable.

Copy link
Contributor Author

Copilot AI commented Nov 2, 2025

@copilot Currently, this change only affects the Shell navigation bar’s TitleView. However, in .NET MAUI developers can also define a TitleView for a standard NavigationPage, like this:

...

Applied the iOS 26 fix to NavigationPage TitleView in commit b802459.

Changes made:

  1. Added CreateTitleViewContainer helper method matching the Shell implementation
  2. Added Container constructor overload accepting navigation bar frame
  3. Refactored initialization logic to reduce duplication
  4. Updated ToolbarHeight to use actual navigation bar height instead of hardcoded 44pt
  5. Added fallback handling when navigation bar frame unavailable

Both Shell and NavigationPage now handle iOS 26+ TitleView layout consistently using autoresizing masks and actual navigation bar dimensions.

Copilot AI changed the title Fix Shell TitleView covering content on iOS 26 Fix Shell and NavigationPage TitleView covering content on iOS 26 Nov 2, 2025
@PureWeen
Copy link
Member

PureWeen commented Nov 2, 2025

/azp run

@PureWeen PureWeen added this to the .NET 10 SR1 milestone Nov 2, 2025
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@kubaflo
Copy link
Contributor

kubaflo commented Nov 2, 2025

@copilot, nice job on the navigation page

Before After


[Test]
[Category(UITestCategories.Shell)]
public void CustomTitleViewDoesNotCoverContent()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can extend the Issue32287 test? Include a rotation test (portrait/landscape) and a dynamic TitleView content size change (e.g., larger font) to verify the container’s frame tracks nav bar changes without covering content

Copy link
Member

Choose a reason for hiding this comment

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

@copilot
Can extend the Issue32287 test? Include a rotation test (portrait/landscape) and a dynamic TitleView content size change (e.g., larger font) to verify the container’s frame tracks nav bar changes without covering content

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extended the Issue32287 test in commit 2579564:

  1. Rotation test - CustomTitleViewDoesNotCoverContentInLandscape() verifies TitleView behavior in landscape mode
  2. Dynamic content tests - CustomTitleViewTracksContentSizeChanges() verifies container adapts when TitleView font size changes
  3. Interactive controls - Added buttons to increase/decrease title font size
  4. TearDown - Properly resets orientation after tests

All rotation tests are wrapped with TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST since orientation changes only work on mobile platforms.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot these tests look good!

Can you create an equivalent version of these tests for NavigationPage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created NavigationPage equivalent tests in commit 5ee5063:

Test Files Created:

  1. Issue32287NavigationPage.xaml - NavigationPage with custom TitleView and interactive controls
  2. Issue32287NavigationPage.xaml.cs - Code-behind with font size adjustment methods
  3. Issue32287NavigationPage.cs - UI tests with three test methods:
    • CustomTitleViewDoesNotCoverContent() - Basic verification
    • CustomTitleViewTracksContentSizeChanges() - Dynamic content size test
    • CustomTitleViewDoesNotCoverContentInLandscape() - Rotation test (iOS/Android)
  4. Placeholder snapshot image for visual validation

The NavigationPage tests mirror the Shell test structure and verify the Container fix handles iOS 26+ layout changes consistently.

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

@copilot delete all the tests from this PR

All the new files added in the tests folder

Deleted all Issue32287 test files as requested:
- Issue32287.xaml and Issue32287.xaml.cs (Shell tests)
- Issue32287NavigationPage.xaml and Issue32287NavigationPage.xaml.cs (NavigationPage tests)
- Issue32287.cs and Issue32287NavigationPage.cs (UI test implementations)

The PR now contains only the iOS 26 TitleView fix implementation without test coverage.

Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Nov 21, 2025
Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot delete all the tests from this PR

All the new files added in the tests folder

Deleted all test files in commit e248773:

Removed files:

  • Issue32287.xaml and Issue32287.xaml.cs (Shell test page)
  • Issue32287NavigationPage.xaml and Issue32287NavigationPage.xaml.cs (NavigationPage test page)
  • Issue32287.cs (Shell UI tests)
  • Issue32287NavigationPage.cs (NavigationPage UI tests)

The PR now contains only the iOS 26 TitleView fix implementation for Shell and NavigationPage without test coverage. Updated the PR description to remove all test-related sections.

@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/backport to release/10.0.1xx-sr1

@github-actions
Copy link
Contributor

Started backporting to release/10.0.1xx-sr1 (link to workflow run)

@PureWeen
Copy link
Member

  • failing tests are unrelated since they are all android and this is only touching ios

@PureWeen PureWeen merged commit 971e326 into main Nov 21, 2025
155 of 164 checks passed
@PureWeen PureWeen deleted the copilot/fix-covering-titleview-issue branch November 21, 2025 18:13
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Nov 21, 2025
kubaflo added a commit to kubaflo/maui that referenced this pull request Nov 28, 2025
Fixes dotnet#32899

The regression was introduced in PR dotnet#32341 where the Height property
was set on the TitleViewContainer for iOS 26+. This interfered with
the UIContainerView's layout logic, preventing images from rendering
properly in Shell.TitleView.

The fix removes the Height property assignment while keeping the Frame
setting, which is sufficient for proper sizing with autoresizing masks.

Changes:
- Removed Height property assignment in TitleViewContainer constructor
- Added UI test case Issue32899 to verify TitleView images display correctly
kubaflo added a commit to kubaflo/maui that referenced this pull request Nov 28, 2025
Fixes dotnet#32899

The regression was introduced in PR dotnet#32341 where the Height property
was set on the TitleViewContainer for iOS 26+. This interfered with
the UIContainerView's layout logic, preventing images from rendering
properly in Shell.TitleView.

The fix removes the Height property assignment while keeping the Frame
setting, which is sufficient for proper sizing with autoresizing masks.

Changes:
- Removed Height property assignment in TitleViewContainer constructor
- Added UI test case Issue32899 to verify TitleView images display correctly
github-actions bot pushed a commit to kubaflo/maui that referenced this pull request Dec 3, 2025
Fixes dotnet#32899

The regression was introduced in PR dotnet#32341 where the Height property
was set on the TitleViewContainer for iOS 26+. This interfered with
the UIContainerView's layout logic, preventing images from rendering
properly in Shell.TitleView.

The fix removes the Height property assignment while keeping the Frame
setting, which is sufficient for proper sizing with autoresizing masks.

Changes:
- Removed Height property assignment in TitleViewContainer constructor
- Added UI test case Issue32899 to verify TitleView images display correctly
PureWeen pushed a commit that referenced this pull request Dec 4, 2025
…26.1 (#32913)

* Fix TitleView image not showing on iOS 26 and macOS 26.1

Fixes #32899

The regression was introduced in PR #32341 where the Height property
was set on the TitleViewContainer for iOS 26+. This interfered with
the UIContainerView's layout logic, preventing images from rendering
properly in Shell.TitleView.

The fix removes the Height property assignment while keeping the Frame
setting, which is sufficient for proper sizing with autoresizing masks.

Changes:
- Removed Height property assignment in TitleViewContainer constructor
- Added UI test case Issue32899 to verify TitleView images display correctly

* Fix TitleView image not showing on iOS 26 and macOS 26.1

* Add UpdateTitleViewInternal for iOS 26+ compatibility

Introduces UpdateTitleViewInternal in ShellPageRendererTracker and calls it from ShellSectionRenderer for iOS 26+ and Mac Catalyst 26+. This ensures TitleView is updated correctly when the ViewController is added to a NavigationController, addressing layout issues on newer OS versions.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-titleview TitleView p/0 Current heighest priority issues that we are targeting for a release.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

TitleView not showing in iOS 26 - .NET10 Using custom TitleView in AppShell causes shell content to be covered in iOS 26

6 participants