首页 > 解决方案 > 在 iPad 上的 inputAssistantItem 中为 UIBarButtonItems 着色

问题描述

我有几个UIBarButtonItems习惯于将格式应用于UITextView. 在 iPhone 上,这些按钮被添加到为 textviewUIToolbar设置的。inputAcessoryView在 iPad 上,按钮被添加到 textview 的inputAssistantItem工具栏中。

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

当将 UIBarButtonItems 添加到 iPhone 上的 UIToolbar 时,这非常有用,但我无法让它为 iPad 上的 inputAssistantItem 工作。当我更改按钮的 tintColor 时,没有任何变化。

标签: iosuibarbuttonitemuitoolbar

解决方案


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


推荐阅读