To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 9.0+
KPInputTextView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'KPInputTextView'
import KPInputTextView
Class YourViewController: UIViewController {
let kpInputView = KPInputTextView()
override var inputAccessoryView: UIView? {
get {
return kpInputView
}
}
override var canBecomeFirstResponder: Bool {
return true
}
override func viewDidLoad() {
super.viewDidLoad()
kpInputView.delegate = self
// Adjust kpInputView's properties here.
kpInputView.backgroundColor = .blue
}
}
extension ViewController: KPInputDelegate {
func didSend(_ text: String) {
// Do something after clicked send button.
// When clicked send button, clear text in inputTextView.
kpInputView.clearTextField()
}
}
Property | Default |
---|---|
backgroundColor | UIColor.lightGray |
textViewBackgroundColor | UIColor.white |
textViewCornerRadius | 10 |
textViewBorderWidth | 1 |
textViewBorderColor | UIColor.black.cgColor |
placeholderText | "message..." |
placeholderTextColor | UIColor.lightGray |
sendButtonTitle | "Send" |
sendButtonTitleColor | UIColor.black |
sendButtonBackgroundColor | UIColor.red |
sendButtonCornerRadius | 7.5 |
sendButtonFont | UIFont.boldSystemFont(ofSize: 14) |
maxLines | 6 |
Function | Description |
---|---|
clearTextField() | Clear text. |
Francis Tseng
KPInputTextView is available under the MIT license. See the LICENSE file for more info.