KEMBAR78
[iOS] Shell/NavigationPage TitleView by kubaflo · Pull Request #20959 · dotnet/maui · GitHub
Skip to content

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Mar 2, 2024

Fixes #9333
Fixes #19231
Fixes #5063

Current behavior

Layout options have no effect on the title view. The content inside the titleView behaves as it has both HorizontalOptions and VerticalOptions set to Fill. Also, notice that there's a horizontal margin that cannot be removed even with setting the negative values to margin eg. Margin="-20,0" (#19231)

Currently

Screenshot 2024-03-02 at 14 58 41

Proposed behavior #5063

Utilizes our current LayoutOptions to indicate how you want a TitleView to layout on the screen and removes the default horizontal margin so that we can customize it.

<NavigationPage.TitleView>
    <HorizontalStackLayout BackgroundColor="red">
        <Label VerticalOptions="Center" Text="Navigation page's title"/>
        <Image Source="dotnet_bot.png" Scale="0.8"/>
    </HorizontalStackLayout>
</NavigationPage.TitleView>

Default - (horizontal and vertical options set to fill implicitly)

Screenshot 2024-03-02 at 15 00 41

HorizontalOptions="Start"

Screenshot 2024-03-02 at 15 02 14

HorizontalOptions="Center"

Screenshot 2024-03-02 at 15 04 44

HorizontalOptions="End"

Screenshot 2024-03-02 at 15 05 47

VerticalOptions="Start"

Screenshot 2024-03-02 at 15 09 49

VerticalOptions="Center"

Screenshot 2024-03-02 at 15 07 58

VerticalOptions="End"

Screenshot 2024-03-02 at 15 06 56

VerticalOptions="Start" HorizontalOptions="Start"

Screenshot 2024-03-02 at 15 15 30

VerticalOptions="Center" HorizontalOptions="Center"

Screenshot 2024-03-02 at 15 14 42

VerticalOptions="End" HorizontalOptions="End"

Screenshot 2024-03-02 at 15 15 07

Remarks

I didn't implement anything that changes the behavior when additional toolbar items are added. For example, if there's a back button the title view places itself to the right of this button. It is because I'm not sure what is the desired behavior. On one hand, it looks weird that when we want to center the title it is moved to the right, but on the other, it is the default iOS's behavior and I believe a future discussion should be made xamarin/Xamarin.Forms#4848
Screenshot 2024-03-02 at 16 10 55

@kubaflo kubaflo requested a review from a team as a code owner March 2, 2024 15:11
@ghost ghost added the community ✨ Community Contribution label Mar 2, 2024
@ghost
Copy link

ghost commented Mar 2, 2024

Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo kubaflo changed the title [iOS] Shell/NavigationPage TitleView (#5063) [iOS] Shell/NavigationPage TitleView Mar 3, 2024
@jsuarezruiz jsuarezruiz added area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-controls-titleview TitleView labels Mar 4, 2024
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Pastajello
Copy link

Pastajello commented Mar 29, 2024

Oh my, never knew I'd see a fix from the issue I suffered from 4 years ago in X.F. days! Are there any plans to add it to .net 8 SR 4? (hopefully)

else if (screenWidth >= 414)
{
// 5.5 inch
spacer.Width -= 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you done tests with 6.1" and 6.7" simulators or devices?

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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.

can you retarget this for net9?

@kubaflo kubaflo changed the base branch from main to net9.0 April 30, 2024 18:04
@kubaflo
Copy link
Contributor Author

kubaflo commented Apr 30, 2024

can you retarget this for net9?

Yep, I think it is a good idea

@TheXenocide
Copy link

can you retarget this for net9?

Yep, I think it is a good idea

Is there no chance we can get this fix in a patch release for .NET 8? Preferably sooner than later? I'm wrestling with this issue at the moment and would really appreciate a fix but we only use LTS versions for production apps.

@TheXenocide
Copy link

I also can't use this code directly in our app because too many pieces are internal for me to drop this in as a replacement renderer.

@jsuarezruiz jsuarezruiz requested a review from PureWeen June 10, 2024 13:44
@nickl-martin
Copy link

Will this be fixed sometime soon? We can't change the color of our navigation bar to anything but white without having unsightly gaps on either end.

@Felix-Dev
Copy link

@kubaflo Any update on this PR? What is blocking progress here?

@kubaflo
Copy link
Contributor Author

kubaflo commented Oct 11, 2024

Hi, @Felix-Dev it is not up to me what will happen with this pr

@rmarinho rmarinho changed the base branch from net9.0 to main October 25, 2024 21:05
@rmarinho
Copy link
Member

/rebase

@Felix-Dev
Copy link

Felix-Dev commented Nov 14, 2024

@PureWeen What is blocking this PR from being merged? The "requested changes" seems to have been addressed by @kubaflo. We are interested in seeing this change land in MAUI. Thanks!

@jbeacham
Copy link

This is also affecting us, an app with millions of users being forced to migrate to MAUI. Huge gaps on either end of the nav bar if we try to do any other color. Any update? Any workaround? @PureWeen

@jbeacham
Copy link

@kubaflo It looks like 2 failing checks. Anything you're familiar with so this can get merged?

@kubaflo
Copy link
Contributor Author

kubaflo commented Nov 19, 2024

@jbeacham Hi!, It's not up to me when and if PRs get merged, but I will rebase this one and solve conflicts :)

@amirvenus
Copy link

I seem to have a similar issue on android too

@dainius-r
Copy link

@kubaflo thanks for PR, have you noticed similar PR for Android, or maybe some workaround?

@kubaflo
Copy link
Contributor Author

kubaflo commented Nov 29, 2024

@dainius-r @amirvenus regarding the left margin: #20967
When it comes to LayoutOptions, I think they are respected on Android

<NavigationPage.TitleView>
    <HorizontalStackLayout HorizontalOptions="End" BackgroundColor="red">
        <Label VerticalOptions="Center"
                Text="Navigation page's title"/>
        <Image Source="dotnet_bot.png"
                Scale="0.8"/>
    </HorizontalStackLayout>
</NavigationPage.TitleView>

@dainius-r
Copy link

@kubaflo many thanks, that's my issue I was lookin for #20967

@YZahringer
Copy link
Contributor

Any update on this PR? What is blocking progress here?

@jfversluis
Copy link
Member

/rebase

@github-actions github-actions bot force-pushed the ios-navigation-bar branch from 8199017 to 0724de7 Compare August 27, 2025 12:31
@Copilot Copilot AI review requested due to automatic review settings August 27, 2025 12:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jfversluis
Copy link
Member

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis jfversluis added this to the .NET 9 SR11 milestone Aug 28, 2025
@jfversluis jfversluis changed the base branch from main to inflight/current August 28, 2025 13:09
@jfversluis jfversluis merged commit 69d8d2c into dotnet:inflight/current Aug 28, 2025
1 check passed
PureWeen pushed a commit that referenced this pull request Sep 8, 2025
Added a comment with a link to Apple docs

Refactor
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-controls-titleview TitleView community ✨ Community Contribution partner/syncfusion/review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Spec] Shell/NavigationPage TitleView [iOS] Wrong default left/right margin in the navigation bar on iOS Unnecessary Margin in TitleView