Skip to content

Instantly share code, notes, and snippets.

View SouzaRodrigo61's full-sized avatar
:octocat:
Working

Rodrigo Santos de Souza SouzaRodrigo61

:octocat:
Working
View GitHub Profile
@SouzaRodrigo61
SouzaRodrigo61 / keyboardHeightObservable.swift
Created May 9, 2021 21:44 — forked from laurilehmijoki/keyboardHeightObservable.swift
RxSwift Observable on iOS keyboard height
import RxSwift // Version 3.2.0
import RxCocoa // Version 3.2.0
func keyboardHeight() -> Observable<CGFloat> {
return Observable
.from([
NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillShow)
.map { notification -> CGFloat in
(notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0
},