Type inconsistency of titleTextAttributes

Originator:an00na
Number:rdar://36179361 Date Originated:December 21 2017, 11:30 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:11.2
Classification:Other Bug Reproducible:Always
 
Area:
UIKit

Summary:
In Swift, titleTextAttributes APIs have inconsistent types:
UINavigationBar.titleTextAttributes: [NSAttributedStringKey : Any]?
UIBarItem.titleTextAttributes(for:): [String : Any]?
UIBarItem.setTitleTextAttributes(_:for:): [NSAttributedStringKey : Any]?
UISegmentedControl.titleTextAttributes(for:): [AnyHashable : Any]?
UISegmentedControl.setTitleTextAttributes(_:for:): [AnyHashable : Any]?
UISearchBar.scopeBarButtonTitleTextAttributes(for:): [String : Any]?
UISearchBar.setScopeBarButtonTitleTextAttributes(_:for:): [String : Any]?

The worst of them is the inconsistency between UIBarItem.titleTextAttributes(for:) and UIBarItem.setTitleTextAttributes(_:for:):
UIBarItem.setTitleTextAttributes to its own titleTextAttributes due to type mismatch.

All these types should be [NSAttributedStringKey : Any]?.

Comments


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!