Navigation Back Button Text Disappears and Doesn't Bring User Back When Using Custom Font

Originator:joshua.shroyer
Number:rdar://FB11344464 Date Originated:August 22nd, 2022
Status:Open Resolved:
Product:UIKit Framework Product Version:At least iOS 14.0 through iOS 16 Beta
Classification:Incorrect/Unexpected Behavior Reproducible:Always
 
# Summary
When using a custom font and appearance proxy for UIBarButtonItems, Navigation Back Button Items (in both UIKit and SwiftUI) will only work if tapped near the front portion of the Back Button. Longer names have a more prominent issue target area. The issue exists at least on iOS 14 through iOS 16 Beta.

# Reproduction Steps 
1. Have a UIKit or SwiftUI application that pushes views onto a Navigation stack. (Must show back button items for previous screens)
2. In code, set `UIBarButtonItem.appearance().setTitleTextAttributes([.font: UIFont.custom], for: .normal)` where `UIFont.custom` is a custom loaded font. (In my attached example projects, this is loaded from a .tff file at app launch)
3. Run the app and push a view onto the navigation stack. (Favor longer Navigation titles for the back button to show to observe the issue)
4. Tap towards the end (right-side in left-to-right languages) of the navigation back button.
5. Observe the text disappears, and the user isn’t brought back. The back arrow remains and can be used to navigate back.

# Expectations
Even with a custom font, I would expect the entire touch target to behave the same way and bring the user back.

# Results Observed
Navigation back button text disappears and doesn’t bring the user back when using a custom font for the back button.

Comments

This was fixed by setting the text attributes on all control states, but the described behavior is still unexpected when only handling the normal control state.

By joshua.shroyer at Nov. 4, 2022, 5:40 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!