textField 的 inputAssistantItem 栏的样式

styling of a textField's inputAssistantItem bar

有没有办法设置包含 inputAssistantItem 元素的柱的 backgroundColor? (图中包含 "next" 按钮的栏):

此外,是否可以向栏中添加 UILabel(如标题)?

我建议您使用 inputAccessoryView,因为它是一个 UIView,您几乎可以用它做任何您想做的事情。

我打开了"UITextInput.h"文件,好像没有办法实现你想要的,对象没有给你工具

这是我找到的代码

NS_CLASS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED __WATCHOS_PROHIBITED @interface UITextInputAssistantItem : NSObject

/// Default is YES, controls if the user is allowed to hide the shortcuts bar. Does not influence the built in auto-hiding logic.
@property (nonatomic, readwrite, assign) BOOL allowsHidingShortcuts;
/// Contains UIBarButtonItemGroups that should be displayed in the leading position on the keyboard's assistant bar.
@property (nonatomic, readwrite, copy) NSArray<UIBarButtonItemGroup *> *leadingBarButtonGroups;
/// Contains UIBarButtonItemGroups that should be displayed in the trailing position on the keyboard's assistant bar.
@property (nonatomic, readwrite, copy) NSArray<UIBarButtonItemGroup *> *trailingBarButtonGroups;

@end

可能的错误解决方案 可能会检查您创建的按钮的超级视图,直到您找到工具栏,然后尝试更改您想要的内容。我真诚地建议您不要这样做