在 iPad 上为 inputAssistantItem 中的 UIBarButtonItems 着色

Tint UIBarButtonItems in inputAssistantItem on iPad

我有几个 UIBarButtonItems 用于将格式应用于 UITextView 中的文本。在 iPhone 上,这些按钮被添加到 UIToolbar 中,该 UIToolbar 被设置为文本视图的 inputAcessoryView。在 iPad 上,按钮被添加到文本视图的 inputAssistantItem 工具栏中。

通过更改 UIBarButtonItems 的 tintColor 可以打开或关闭按钮的状态(即当当前选择的 NSRange 应该是粗体时,粗体按钮的 tintColor 会更改以指示它处于活动状态)。

在 iPhone 上将 UIBarButtonItems 添加到 UIToolbar 时效果很好,但我无法在 iPad 上将其用于 inputAssistantItem。当我更改按钮的 tintColor 时,没有任何变化。

对于任何感兴趣的人,我设法通过向每个 UIBarButtonItem 添加一个 UIButton 然后更改按钮的 tintColor 而不是 UIBarButtonItem 来解决这个问题。