KeyboardInsetHelper

open class KeyboardInsetHelper : NSObject

Binds keyboard appearance and metrics to scroll view content and scroll bar insets and/or a layout constraint relative to reference view. This object can be created and linked in a sotryboard.

  • Deprecated: Please use minimumInset instead.

    Refer to the documentation for minimumInset for more info.

    Declaration

    Swift

    @available(*, deprecated, renamed: "minimumInset")
    @IBInspectable
    public var baseInset: CGFloat { get set }
  • The minimum inset value. Inset values below this value are clamped to minimumInset. Defaults to 0

    Declaration

    Swift

    @IBInspectable
    public var minimumInset: CGFloat
  • The inset and constraint constant will be calculated in the coordinates of this view. This variable must be non-nil, otherwise the insets won’t get updated.

    Declaration

    Swift

    @IBOutlet
    public weak var referenceView: UIView?
  • Scroll view to adjust content inset at. When the keyboard appears or disappears, the inset will be adjusted to align the bottom of the scroll view’s content with the top of the keyboard (minimumInset takes priority).

    Declaration

    Swift

    @IBOutlet
    public weak var scrollView: UIScrollView?
  • When the keyboard appears or disappears, the constraint’s constant will be set to the distance between the bottom of the reference view and the top of the keyboard but no less than minimumInset.

    Declaration

    Swift

    @IBOutlet
    public weak var constraint: NSLayoutConstraint?
  • Initializes a new KeyboardInsetHelper with default values.

    Declaration

    Swift

    public override init()
  • Deprecated: Please use updateForInset(_:, base:) instead.

    Refer to the documentation for updateForInset(_:, base:) for more info.

    Declaration

    Swift

    @available(*, deprecated, renamed: "updateForInset(_:base:﹚")
    @objc
    open func updateForInset(_ inset: CGFloat)
  • Do the default actions when the keyboard insets change.

    The default implementation of this method:

    • Updates the scrollView‘s contentInset.bottom and scrollIndicatorInsets.bottom to that of the inset parameter
    • Sets the constraint’s constant to the inset parameter
    • Call layoutIfNeeded on the reference view

    Declaration

    Swift

    open func updateForInset(_ inset: CGFloat, base baseInset: CGFloat)