-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Shell/navigation page title view - respect the margin property #31701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] Shell/navigation page title view - respect the margin property #31701
Conversation
There was a problem hiding this 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.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
|
@sheiksyedm can you test this pr please |
|
I did a quick test of this PR using the sample project from dotnet/maui#31688 With this PR, the navigation bar title view now includes some default margin, resulting in a layout consistent with earlier MAUI versions. Fine-tuning the positioning of the title view by applying negative left and positive right margins, works well. 👍 |
|
@kubaflo Please resave the latest iOS and Mac image from the CI run. |
Yes, I tested this fix, and it resolves the failures. LGTM. |
|
/rebase |
37d4363 to
091d0e8
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
@kubaflo Where is that -20 Margin coming from to align the TitleView with the edges of the screen? Ideally, I as developer don't want to guess/experiment what the correct negative offset here would be to correctly align the the view to the edges. If that -20 value is a value based on official data, could something like a resource be added to MAUI which developers could then reference to properly remove the default margin entirely? |
Yeah, that’s the tricky part - iOS doesn’t expose any public API (at least none that I know of) to reliably remove or control that default margin. To make it more complicated, the margin itself isn’t consistent: it can vary depending on screen size, device orientation, and even whether the “Back” text is shown in the navigation bar. Because of that, if MAUI were to just hard-code the margin to 0, it would actually cause more layout issues than it solves. Without an official value from Apple or a stable API to query, the safest option for now is to preserve the native behavior and let developers apply their own negative margin when they want to override it. |
Replaces the custom CalculateUIEdgeInsets method with an override of AlignmentRectInsets that leverages the IView.Margin property. This ensures the alignment insets reflect the view’s actual margins, allowing developers to align the TitleView directly with the screen edges.
Replaces the custom CalculateUIEdgeInsets method with an override of AlignmentRectInsets that leverages the IView.Margin property. This ensures the alignment insets reflect the view’s actual margins, allowing developers to align the TitleView directly with the screen edges.
091d0e8 to
7ceac33
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…31701) * [iOS] Shell/NavigationPage TitleView Replaces the custom CalculateUIEdgeInsets method with an override of AlignmentRectInsets that leverages the IView.Margin property. This ensures the alignment insets reflect the view’s actual margins, allowing developers to align the TitleView directly with the screen edges. * [iOS] Shell/NavigationPage TitleView Replaces the custom CalculateUIEdgeInsets method with an override of AlignmentRectInsets that leverages the IView.Margin property. This ensures the alignment insets reflect the view’s actual margins, allowing developers to align the TitleView directly with the screen edges.
…31701) * [iOS] Shell/NavigationPage TitleView Replaces the custom CalculateUIEdgeInsets method with an override of AlignmentRectInsets that leverages the IView.Margin property. This ensures the alignment insets reflect the view’s actual margins, allowing developers to align the TitleView directly with the screen edges. * [iOS] Shell/NavigationPage TitleView Replaces the custom CalculateUIEdgeInsets method with an override of AlignmentRectInsets that leverages the IView.Margin property. This ensures the alignment insets reflect the view’s actual margins, allowing developers to align the TitleView directly with the screen edges.

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 of Change
On iOS, the NavigationPage TitleView is currently overflowing, causing its content to be cut off.
This appears to be related to #20959, which removed the default margin.
While the extra margin was not ideal and the change was meant to improve alignment, it introduced new layout issues (as discussed in #31688.
This PR refines that behavior:
Issues Fixed
Fixes #31688
Fixes #31681 (comment)