Skip to content

Centering Navigation Title#2200

Merged
JaquelineGomez merged 12 commits intomicrosoft:mainfrom
JaquelineGomez:user/jagomez/centerNavTitle
Aug 21, 2025
Merged

Centering Navigation Title#2200
JaquelineGomez merged 12 commits intomicrosoft:mainfrom
JaquelineGomez:user/jagomez/centerNavTitle

Conversation

@JaquelineGomez
Copy link
Copy Markdown
Contributor

@JaquelineGomez JaquelineGomez commented Aug 21, 2025

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

In iOS 26, the containingStackView (which manages the title and subtitle) was expanding to fill the entire available space to the right of the back button, causing the text to be centered within this oversized container rather than within the navigation bar itself. This resulted in visually off-center navigation titles. This fix calculates the minimum space required by the containingStackView to properly display all its content, allowing the navigation controller to center the appropriately-sized container within the navigation bar for proper title alignment.

Verification

iPhone 16 Pro with iOS 26 and iOS 18 (no affect on iOS 18)
iPad iOS 16

Visual Verification
Before After
image image
image image

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@JaquelineGomez JaquelineGomez requested a review from a team as a code owner August 21, 2025 21:01
@joannaquu
Copy link
Copy Markdown
Contributor

just double checking, after initial setup, do we ever do a layout change that would require a call to invalidateIntrinsicContentSize

@joannaquu
Copy link
Copy Markdown
Contributor

nit: can we rename pr title

@JaquelineGomez JaquelineGomez changed the title User/jagomez/center nav title Centering Navigation Title Aug 21, 2025
@JaquelineGomez
Copy link
Copy Markdown
Contributor Author

just double checking, after initial setup, do we ever do a layout change that would require a call to invalidateIntrinsicContentSize

The navigation title is not being changed meaning the size does not change, so no.

Also tested with rotating the device and it still has the title centered correctly.

@JaquelineGomez JaquelineGomez merged commit d1a8e97 into microsoft:main Aug 21, 2025
7 checks passed
@joannaquu joannaquu mentioned this pull request Oct 23, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants