CombineKeyboard is a way to getting keyboard frame or height with Combine, inspired by the RxSwift Community's RxKeyboard library.
CombineKeyboard provides three Publishers. (If you want more Publisher, you can contributes this library)
/// A publisher emitting current keyboard `frame`
/// You will be returned the current keyboard `frame` at start of subscription.
public var frame: AnyPublisher<CGRect, Never>
/// A publisher emitting current keyboard `height`
/// You will be returned the current keyboard `height` at start of subscription.
public var height: AnyPublisher<CGFloat, Never>
/// A publisher emitting current keyboard `height` when keyboard's height is updated
public var heightUpdated: AnyPublisher<CGFloat, Never>You can use three Publishers with CombineKeyboard.shared
CombineKeyboard.shared.frame
.sink(receiveValue: { frame: CGRect in
print(frame)
})
.store(in: &cancellables)
CombineKeyboard.shared.height
.sink(receiveValue: { currentHeight: CGFloat in
print(currentHeight)
})
.store(in: &cancellables)
CombineKeyboard.shared.heightUpdated
.sink(receiveValue: { height: CGFloat in
print(height)
})
.store(in: &cancellables)- Swift 5
- iOS 13 +
CombineKeyboard is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CombineKeyboard'CombineKeyboard is available under the MIT license. See the LICENSE file for more info.
This Library was made inspired by RxKeyboard library. thanks to RxKeyboard's Contributers