@@ -14,6 +14,7 @@ A customizable, expandable, and easy-to-use input accessory view component for i
1414
1515The main features are:
1616
17+ * Responsively uses ` UITextInputAssistantItem ` on iPad and ` UITextInputView ` on iPhone.
1718* Scrollable input accessory view with blurry background and customizable buttons.
1819* Supports Auto Layout and Safe Area.
1920* Supports dark mode.
@@ -24,8 +25,8 @@ The main features are:
2425
2526### Requirements
2627
27- * iOS 13 .0+
28- * Swift 5.3 +
28+ * iOS 14 .0+
29+ * Swift 5.5 +
2930
3031### Installation
3132
@@ -44,48 +45,29 @@ To run the example project, clone the repo, and run `pod install` from the Examp
4445``` swift
4546// Create view model array of key buttons
4647let keyButtons: [KeyboardAccessoryButton] = [
47- // Create button with built-in type and tap handler block
48- KeyboardAccessoryButton (type : .undo ) { [weak self ] in
48+ // Create button with built-in type and tap handler block that will be placed on
49+ // the leading side of keyboard on iPad
50+ KeyboardAccessoryButton (type : .undo , position : .leading ) { [weak self ] in
4951 self ? .undo ()
5052 },
51- // Create button with UIImage
52- KeyboardAccessoryButton (image : UIImage (named : " img" ), tapHandler : {} ),
53+ // Create button with UIImage that will be collapsed in an overflow menu on iPad
54+ KeyboardAccessoryButton (image : UIImage (named : " img" ), position : . overflow ),
5355 // Create button with title
54- KeyboardAccessoryButton (title : " Button" , tapHandler : {}),
56+ KeyboardAccessoryButton (title : " Button" ,
5557 // Create button with UIMenu
5658 KeyboardAccessoryButton (type : .link , menu : createInsertMenu ()),
5759]
5860
59- // Initialize `KeyboardAccessoryView`
60- let accessoryView = KeyboardAccessoryView (
61- frame : CGRect (x : 0 , y : 0 , width : view.frame .width , height : 0 ),
61+ // Initialize and retain `KeyboardAccessoryManager`
62+ self .accessoryManager = KeyboardAccessoryView (
6263 keyButtons : keyButtons,
6364 showDismissKeyboardKey : true ,
6465 delegate : self )
6566
66- // Assign the accessory view instance to `UITextView`
67- textView.inputAccessoryView = accessoryView
68-
69- // Set tint color for the whole view
70- accessoryView.tintColor = .systemPink
71- // ...or at a given index
72- accessoryView.setTintColor (.systemGreen , at : 5 )
73-
74- // Set enabled at a given index
75- accessoryView.setEnabled (false , at : 1 )
67+ // Configures the `UITextView` with `KeyboardAccessoryManager`
68+ self .accessoryManager .configure (textView : textView)
7669```
7770
78- ## TODO
79-
80- - [x] Support text title
81- - [ ] Expose more APIs for customization
82- - [x] Tint color
83- - [ ] Tweak UI
84- - [x] Use SF Symbol
85- - [x] UIMenu support
86- - [ ] UIAction support
87- - [x] SPM support
88-
8971## License
9072
9173AccessoryKit is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
0 commit comments