Enumeration
KeyboardObserver
public enum KeyboardObserver
Keyboard observer is a namespace for subscription static methods
Methods
addObserver(_:_:)
public static func addObserver(
_ notificationCenter: NotificationCenter = .default,
_ observer: @escaping KeyboardManagerEventClosure
) -> KeyboardObserverToken
Add observer closure for observing keyboard events
Parameters
Name | Type | Description |
---|---|---|
notificationCenter | NotificationCenter |
notification center to observe notifications |
observer | @escaping KeyboardManagerEventClosure |
closure for observing events |
Returns
observer token that store subscription
addObserver(_:superview:bottomConstraint:bottomOffset:safeAreaInsets:animated:)
public static func addObserver(
_ notificationCenter: NotificationCenter = .default,
superview: UIView,
bottomConstraint: NSLayoutConstraint,
bottomOffset: CGFloat = 0.0,
safeAreaInsets: @escaping () -> UIEdgeInsets = { UIEdgeInsets.zero },
animated: Bool = false
) -> KeyboardObserverToken
Automatically adjusts view's bottom constraint offset after receiving keyboard's notifications
Parameters
Name | Type | Description |
---|---|---|
notificationCenter | NotificationCenter |
notification center to observe notifications |
superview | UIView |
parent view for adjusted constraints |
bottomConstraint | NSLayoutConstraint |
current bottom constraint instance |
bottomOffset | CGFloat |
minimal preserved constraint offset value |
safeAreaInsets | @escaping () -> UIEdgeInsets |
safe area generator for compensate offset for view controllers with tabbar |
animated | Bool |
should changes be animated |
Returns
observer token that store subscription
addObserver(_:scrollView:)
public static func addObserver(
_ notificationCenter: NotificationCenter = .default,
scrollView: UIScrollView
) -> KeyboardObserverToken
Automatically adjusts scrollView's contentInset property with animation after receiving keyboard's notifications
Parameters
Name | Type | Description |
---|---|---|
notificationCenter | NotificationCenter |
notification center to observe notifications |
scrollView | UIScrollView |
scroll view instance |
Returns
observer token that store subscription